next.js: Build error next.js 6.0.0

I just upgraded to next@6.0.0, I use a custom server, when I try to run dev, I get an error.

npm run dev

> frontend-next@1.0.0 dev /Users/foo/gitlab/next-project/backend
> babel-node ./src/server.js

/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
        throw e;
        ^

Error: Plugin 0 specified in "/Users/foo/gitlab/next-project/backend/node_modules/next/babel.js" provided an invalid property of "default" (While processing preset: "/Users/foo/gitlab/next-project/backend/node_modules/next/babel.js")
    at Plugin.init (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/plugin.js:131:13)
    at Function.normalisePlugin (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:152:12)
    at /Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
    at Array.map (<anonymous>)
    at Function.normalisePlugins (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
    at OptionManager.mergeOptions (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
    at /Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
    at /Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend-next@1.0.0 dev: `babel-node ./src/server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the frontend-next@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/foo/.npm/_logs/2018-04-30T08_41_09_819Z-debug.log

UPDATE all this passed after upgrading all babel packages to v7

Now this is the new error… See below for complete error message

ERROR  Failed to compile with 1 errors                                                                                                                                                                                               10:32:07

 error  in ./pages/_document.js

Module build failed: Error: [BABEL] /Users/foo/gitlab/zyombo/backend/pages/_document.js: .value is not a valid Plugin property

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 24
  • Comments: 125 (27 by maintainers)

Commits related to this issue

Most upvoted comments

I have this exact same issue with Babel and Next.

@GabrielDuarteM to fix babel-jest install: "babel-core": "7.0.0-bridge.0"

npm i babel-loader@7 --save-dev fixed it for me.

The only way I could make it work was by running https://github.com/babel/babel-upgrade which upgrades any babel transformations you’re using.

And I changed my .babelrc file:

{
  "presets": ["@babel/env", "next/babel"]
}

Also if you’re using jest upgrade babel-jest to the latest version and install “babel-core”: “7.0.0-bridge.0”.

I’m switching back to 5 due to the .value is not a valid Plugin property in development mode with a custom (express) server. Tried all the suggestions here with no success 😦

So I forced beta42 deps, nuked node_modules and used yarn instead of npm (v6), and it’s working fine again. W-T-F.

There is sth wrong with npm deps resolution.

@timneutkens There is a lot of duplicated effort as people individually discover forcing resolutions in yarn (and even having to switch to yarn), and unfortunately most of this knowledge is held in this closed thread. Are there plans to update next6 to a later babel beta version in order to fix this problem (outside of the forks like https://github.com/zeit/next.js/issues/4227#issuecomment-387446918, which I suppose could’ve been a PR)? Or is the official plan to wait until babel 7 full release unless a good PR comes in?

Finally, I’ve found simplest way to fixed it in next 6.0.0 +

just put babel config like this

/server/.babelrc

{
  "presets": [
    "@babel/preset-env"
  ]
}

devDependencies + start script

"scripts": {
    "dev": "babel-node ./server/server.js",
    "build": "next build; babel server -d dist --copy-files",
    "start": "node ./dist/server.js"
} ,
"devDependencies": {
    "@babel/cli": "7.0.0-beta.48",
    "@babel/core": "7.0.0-beta.48",
    "@babel/node": "7.0.0-beta.48",
    "@babel/preset-env": "7.0.0-beta.48"
}

For the people getting the

<project root>\jest.setup.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { configure } from "enzyme"
                                                                                                    ^

    SyntaxError: Unexpected token {

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)

error, my recommendation would be to install babel-jest. At least in my tests, it appears to be installed in the wrong place, making Jest unable to load it properly.

If you’re seeing the error

Plugin 0 specified in “<root>/node_modules/next/babel.js” provided an invalid property of “default” (While processing preset: …

As mentioned above, you are using a combination of Babel 6 and Babel 7.

As for

.value is not a valid Plugin property

I personally have not been able to reproduce it yet. If someone could make an example repository that I can clone, I’d be happy to take a look.

Continued looking at this this morning. I threw together this super simple example app which for me reproduces the error every time.

https://github.com/ljanssen5/next-test

While playing around with this, I noticed that if I remove the devDependency of babel/core or babel-loader, everything works fine. If they are both there though, the error occurs. So not positive what the issue is exactly yet, but it seems to me that babel-loader 8.0.0-beta.2 and @babel/core 7.0.0-beta.46 are not jiving.

I got this to work finally! next - v6.0.3.

Basically:

  1. rm -rf node_modules
  2. rm -rf .next
  3. rm package-lock.json
  4. npm i
  5. rm .babelrc

We are switching to .babelrc.js - it is easier to manage and works.

Every change you make do those 5 steps. Do not use ^ or ~ for the babel stuff, since it will upgrade you to .49 and that will not work. Also some modules 42, 44 etc will not work. Make sure all are 42.

I noticed that you need to delete package-lock.json and then run npm i to fix it.

To run my tests:

  1. To test prod mode: NODE_ENV=production npx next build, then NODE_ENV=production npx node index OR NODE_ENV=production npx next if you are not using the index.js way. We use Node to set routes, etc.

  2. To test running in browser with webpack: NODE_ENV=development npx node index or NODE_ENV=development npx next

  3. NODE_ENV=production BABEL_ENV=test npx jest – that is to test using jest

package.json parts:

  "dependencies": {
    "@babel/cli": "7.0.0-beta.42",
    "@babel/core": "7.0.0-beta.42",
    "@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.42",
    "@babel/preset-env": "7.0.0-beta.42",
    "@babel/preset-react": "7.0.0-beta.42",
    "@zeit/next-typescript": "^1.0.1",
     "next": "~6.0.3",
      "jest": "^22.4.3",
      "ts-jest": "^22.4.5",
       "ts-loader": "^3.5.0",
     "babel-loader": "^8.0.0-beta.3",
     "babel-plugin-module-resolver": "^3.1.1"
 "devDependencies": {
    "@babel/core": "7.0.0-beta.42",
    "@babel/plugin-proposal-class-properties": "7.0.0-beta.42",
    "apollo-link-schema": "^1.1.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^7.2.3",
    "babel-jest": "^22.4.4",
    "babel-plugin-add-module-exports": "^0.2.1",
    "babel-preset-es2015": "^6.24.1",
    "jest": "^22.4.3",
}

Later in package.json setup jest:

"jest": {
    "transform": {
      "^.+\\.tsx?$": "babel-jest",
      "^.+\\.jsx?$": "babel-jest"
    },
    "testRegex": "(/__tests__/.*(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
    "testPathIgnorePatterns": [
      "/.next/",
      "/node_modules/"
    ],
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ],
    "moduleNameMapper": {
      "\\~(.*)$": "<rootDir>/core/components/$1",
      "\\^(.*)$": "<rootDir>/core/styles/$1",
      "@(?!babel|rules)(.*)$": "<rootDir>/core/$1",
      "\\$(.*)$": "<rootDir>/$1"
    },
    "setupTestFrameworkScriptFile": "<rootDir>/tests/setupTestFrameworkScript.js",
    "coverageDirectory": "<rootDir>/coverage/",
    "coveragePathIgnorePatterns": [
      "/node_modules/",
      "/.next/",
      "/coverage/"
    ],
    "setupFiles": [
      "<rootDir>/tests/setupTests.js"
    ],
    "globals": {
      "ts-jest": {
        "useBabelrc": true
      }
    }

next.config.js

const glob = require('glob')
const withTypeScript = require('@zeit/next-typescript')
const webpack = require('webpack')

module.exports = withTypeScript({
  webpack (config, options) {
    console.log(options)
    const { isServer } = options

    config.plugins = config.plugins.filter(plugin => {
      if (plugin.constructor.name === 'UglifyJsPlugin') {
        return false
      } else {
        return true
      }
    })
    if (isServer === false) {
      config.plugins.push(
        new webpack.IgnorePlugin(/(worker-farm|fsevents|readline|express)/)
      )
      config.plugins.push(
        new webpack.IgnorePlugin(/node_modules\/worker-farm\/lib\/fork\.js/)
      )
      config.node = {fs: 'empty', 'express': 'empty', 'module': 'empty'}
    }
    config.module.rules.push({
      test: /\.+(js|jsx|ts|tsx)$/,
      exclude: /node_modules/,
      use: {loader: 'babel-loader'}
    })
    config.module.rules.push({
      test: /pages.*\.test\.+(js|jsx|ts|tsx)$/,
      loader: 'ignore-loader'
    })
    console.log(config)
    return config
  },
  exportPathMap () {
    const pathMap = {}
    glob.sync('pages/**/*.js', {ignore: 'pages/_document.js'}).forEach(s => {
      const path = s.split(/(pages|\.)/)[2].replace(/^\/index$/, '/')
      pathMap[path] = {page: path}
    })
    return pathMap
  }

})

And .babelrc.js

const path = require('path');

console.log('next.config.js --->', path.resolve('./'))

module.exports = {
  "env": {
    "test": {
      "presets": ["@babel/preset-env", "next/babel", "@zeit/next-typescript/babel"],
      "plugins": [
        "@babel/plugin-proposal-object-rest-spread",
        ["module-resolver", {
          "root": [path.resolve('./')],
          "alias": {
            "\\~": "./core/components",
            "\\^": "./core/styles",
            "\\@": "./core",
            "\\$": "./"
          }
        }]
      ]
    },
    "production": {
      "presets": ["next/babel", "@zeit/next-typescript/babel"],
      "plugins": [
        ["module-resolver", {
          "root": [path.resolve('./')],
          "alias": {
            "\\~": "./core/components",
            "\\^": "./core/styles",
            "\\@": "./core",
            "\\$": "./"
          }
        }]
      ]
    },
    "development": {
      "presets": ["next/babel", "@zeit/next-typescript/babel"],
      "plugins": [
        ["module-resolver", {
          "root": [path.resolve('./')],
          "alias": {
            "\\~": "./core/components",
            "\\^": "./core/styles",
            "\\@": "./core",
            "\\$": "./"
          }
        }]
      ]
    }
  }
}

next@6.0.0 uses 7.0.0-beta.42.

From my debugging it seems that the babel-loader in Next.js’s default config has two plugins.

https://github.com/zeit/next.js/blob/canary/server/build/webpack.js#L18-L19

They are ConfigItems which are created by Next.js upfront for caching/performance purposes.

It is the .value being read on these ConfigItems that is causing the error during validation. They should be transformed into plugin objects I think, but they are failing to do so.

@babel/core#createConfigItem is used to create the ConfigItems.

Maybe the version differences are responsible as @ewagstaff observed? Maybe there were changes made to the createConfigItem api?

…maybe I am on the wrong track too. It’s very tricky to figure out what is going on.


If I comment out https://github.com/zeit/next.js/blob/canary/server/build/webpack.js#L37-L40 the error disappears.


If I stop using createConfigItem the error also disappears:


//var presetItem = (0, _core.createConfigItem)(require('./babel/preset'), {
//  type: 'preset'
//});
//var hotLoaderItem = (0, _core.createConfigItem)(require('react-hot-loader/babel'), {
//  type: 'plugin'
//});
//var reactJsxSourceItem = (0, _core.createConfigItem)(require('@babel/plugin-transform-react-jsx-source'), {
//  type: 'plugin'
//});

var presetItem = require('./babel/preset')
var hotLoaderItem = require('react-hot-loader/babel')
var reactJsxSourceItem = require('@babel/plugin-transform-react-jsx-source')

My best guess is…

The issue is probably caused by a change to the createConfigItem api from 42 -> 46, or perhaps @babel/core is being used as a singleton and storing the cached config, which the other instance of @babel/core cannot access.

Maybe @loganfsmyth can shed some light?

So lets first start with explaining that you should never add @babel/preset-env or babel-preset-env to your .babelrc, since it breaks code splitting with webpack.

Instead you can provide options to next/babel:

{
  "presets": [
    ["next/babel", {
	 "preset-env": {
       "targets": {
         "browsers": "> 5%"
       }
     }
	}]
  ]
}

Also when providing options don’t set modules: true since that breaks code splitting too.

Besides that try running https://github.com/babel/babel-upgrade to upgrade your .babelrc, it takes care of most of the modules that have to be upgraded.

I’m having this issue too. To create an app reproducing the problem you can create a new app based off the with-jest example in this very repo:

yarn create next-app --example with-jest with-jest-app
cd with-jest-app
yarn
yarn test

Here’s the output for that last command:

yarn run v1.5.1
$ NODE_ENV=test jest
 FAIL  components/Header.test.js
  ● Test suite failed to run

    Plugin 0 specified in "/Users/ernesto/code/with-jest-app/node_modules/next/babel.js" provided an invalid property of "default" (While processing preset: "/Users/ernesto/code/with-jest-app/node_modules/next/babel.js")

      at Plugin.init (node_modules/babel-core/lib/transformation/plugin.js:131:13)
      at Function.normalisePlugin (node_modules/babel-core/lib/transformation/file/options/option-manager.js:152:12)
      at node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
          at Array.map (<anonymous>)
      at Function.normalisePlugins (node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
      at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
      at node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
      at node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
          at Array.map (<anonymous>)
      at OptionManager.resolvePresets (node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.005s
Ran all test suites.
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c NODE_ENV=test jest
Directory: /Users/ernesto/code/with-jest-app
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/ernesto/code/with-jest-app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

However, yarn dev works flawlessly.

There’s 2 options:

  1. you don’t, there’s really no need to transpile it if you’re using the custom server correctly (just implementing routing / caching)

  2. you put the server into a separate directory server add a server/.babelrc and let babel compile using that.

I am also getting that error: _document.js: .value is not a valid Plugin property

It appears somehow linked to babel/core – it only appears after I explicitly install it. Here’s my fallback package.json (I don’t get the error with this list of dependencies):

{
  "name": "future-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "next",
    "build": "next build && next export",
    "start": "next start"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@babel/preset-env": "^7.0.0-beta.46",
    "@babel/preset-react": "^7.0.0-beta.46",
    "@zeit/next-less": "^0.2.0",
    "babel-plugin-inline-dotenv": "^1.1.2",
    "babel-plugin-transform-inline-environment-variables": "^0.4.1",
    "less": "^2.7.3",
    "next": "^6.0.0",
    "react": "^16.3.2",
    "react-dom": "^16.3.2"
  }
}

EDIT: More detail – babel/core v 7.0.0-beta.46 definitely does appear to be the culprit. No issues if I explicitly install v 7.0.0-beta.42.

@paschaldev if you define settings per environment using env in your .babelrc, you should put all config inside env, and duplicate the config for each environment (except for the differences of course). For example, here’s mine:

{
  "env": {
    "development": {
      "presets": ["next/babel"],
      "plugins": [
        ["styled-components", { "ssr": true, "displayName": true, "preprocess": false }],
        ["inline-react-svg"]
      ]
    },
    "production": {
      "presets": ["next/babel"],
      "plugins": [
        ["styled-components", { "ssr": true, "displayName": false, "preprocess": false }],
        ["inline-react-svg"]
      ]
    },
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]],
      "plugins": [
        ["styled-components", { "ssr": true, "displayName": false, "preprocess": false }],
        ["inline-react-svg"]
      ]
    }
  }
}

Yes, it’s ugly, but it works.

facing same issue, babelrc

{
  "presets": [
    "env",
    "next/babel",
    "stage-2",
    "es2015"],
  "plugins": [
    [
      "module-resolver",
      {
        "root": ["./"]
      }
    ]
  ],
  "env": {
    "development": {
      "presets": ["next/babel"]
    },
    "production": {
      "presets": ["next/babel"]
    },
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]]
    }
  }
}

dependencies (from package.json)

"@material-ui/core": "^1.5.1",
    "@zeit/next-css": "^0.2.0",
    "@zeit/next-sass": "^0.2.0",
    "babel-loader": "^7.1.5",
    "babel-preset-env": "^1.7.0",
    "enzyme": "^3.4.4",
    "enzyme-adapter-react-16": "^1.2.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "22.4.3",
    "babel-plugin-module-resolver": "^3.1.1",
    "jest": "^23.5.0",
    "react-test-renderer": "^16.4.2",
    "react-addons-test-utils": "^15.6.2",
    "file-loader": "^2.0.0",
    "isomorphic-unfetch": "^2.1.1",
    "next": "^6.1.1",
    "node-sass": "^4.9.3",
    "postcss-css-variables": "^0.9.0",
    "postcss-loader": "^3.0.0",
    "raw-loader": "^0.5.1",
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-devtools-extension": "^2.13.5",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0",
    "semantic-ui-css": "^2.3.3",
    "semantic-ui-react": "^0.82.3",
    "url-loader": "^1.1.1"

error

FAIL components/GraphComponent/GraphComponent.spec.js ● Test suite failed to run

Plugin 0 specified in "/Users/prashanthnaika/Documents/Projects/tweettraders-ui/node_modules/next/babel.js" provided an invalid property of "default" (While processing preset: "/Users/prashanthnaika/Documents/Projects/tweettraders-ui/node_modules/next/babel.js")

  at Plugin.init (node_modules/jest-config/node_modules/babel-core/lib/transformation/plugin.js:131:13)
      at Array.map (<anonymous>)
      at Array.map (<anonymous>)

For me the solution was to install babel-loader@7. I inspected the @babel/core/lib/config/validation/plugins.js module and the value coming into L86 was very off.

ConfigItem {
  value: [Function: plugin],
  options: undefined,
  dirname: '/home/gnagatomo/workspace/frontend',
  name: undefined,
  file: undefined }
ConfigItem {
  value: [Function],
  options: undefined,
  dirname: '/home/gnagatomo/workspace/frontend',
  name: undefined,
  file: undefined }

That’s when it hit me that maybe the loader was incompatible. Downgrading babel-loader to 7 was the only change needed to correct the issue for me.

I think a migration guide is strongly needed for a better user experience, because the release notes doesn’t help at all when looking for breaking changes.

Facing the same problem, here is my .babelrc:

{
  "presets": ["next/babel", "@babel/preset-flow"],
  "plugins": [
    ["styled-components", { "ssr": true, "displayName": true, "preprocess": false }],
    [
      "module-resolver",
      {
        "root": ["./web"],
        "alias": {
          "~": "./web"
        }
      }
    ]
  ],
  "env": {
    "development": {
      "plugins": ["inline-dotenv"]
    },
    "production": {
      "plugins": ["transform-inline-environment-variables"]
    }
  }
}

I was finally able to get past this issue. However my solution may not work for all. The app I am working on has a very simple babel setup as seen below.

{
  "presets": [
    "next/babel",
    "@babel/preset-env"
  ]
}

Once I realized that next was already taking care of babel/preset-env, I realized I didnt need to be using a custom babelrc at all or installing any babel packages in my packages.json. After cleaning out the packages.json of babel packages and deleting .babelrc, I am back in business.

I don’t believe this solution is going to work for everyone as I assume some are going to need to use custom .babelrc, but thought I’d share in case others find themselves in a similar boat as I was.

@khacthanh244 You should use commonjs modules in .babelrc.js. Don’t forget to update babel-plugin-transform-define to 1.3.0

// .babelrc.js
const env = require("./env-config.js");

module.exports = {
  presets: ["next/babel"],
  plugins: [["transform-define", env]]
};

@joaovieira thanks for your response. i changed my project, but the tests are failing when i am using JavaScript variables in the styles.

like

background-color: ${gray};

my test-presets:

"presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }], "@zeit/next-typescript/babel"]

Do you have any clue to solve this? Thanks 😃

For me, this same error resulted from an issue with yarn.

The following steps resulted in the error below:

  1. Deleting node_modules
  2. Installing dependencies with yarn or yarn install
  3. Starting my app using package.json script for node server/index.js gave me the error:
ERROR  Failed to compile with 1 errors

 error  in ./pages/_document.js

Module build failed: Error: [BABEL] [...]/pages/_document.js: .value is not a valid Plugin property

Replacing step 2 with npm install enabled me to start my app without any issues though.

To get yarn back in working order, I simply uninstalled and reinstalled yarn globally. Now, running yarn to install these dependencies works just fine and I don’t get this error.

Hopefully that will help someone else here.

I got the same issue here, but interestingly enough, after I adjusted my custom webpack configuration, it went away.

The context is this. I fresh-started a new project using Next.js 6 few days ago, for which I could see what code change introduced the problem. It’s kind of weird, but I never took care of Babel versions I depend on. The issue happened only after I customized webpack configuration using next.config.js. My suspect was webpack-merge, and after manually implementing the merge, build started to work again.

I didn’t inspect further, but if someone uses a kind of the library, I think just not using it might help. (webpack-merge has no Babel dependency!)

Hope someone find the exact cause of this problem.

@vjpr Right, my polyfill issue was simply a caching issue. The real culprit was my use of https://github.com/survivejs/webpack-merge in next.config.js. After removing it the error is gone.

@vjpr

Is this an api issue, or is @babel/core used as a singleton to store state?

We use instanceof ConfigItem so if you create a config item from a different copy of babel, then that check will fail. If we land https://github.com/babel/babel-loader/issues/598 this should be resolved anyway, so I’ll see if I can get that done soon.

Hi @GabrielDuarteM I’ve just solved probably the same issue like yours, after changing the babel-core to the supported version which is 7.0.0-bridge.0, the next thing you need to do is to change the _modules_ value to anything you want except true, because it doesnt accept true value anymore. Since this error told me so Invariant Violation: [BABEL] /Users/mokapos/node/next-blog/jest.setup.js: Invalid Option: The 'modules' option m ust be either 'false' to indicate no modules, or a module type which can be be one of: 'commonjs' (default), 'amd', 'umd', 'systemjs'. (While processing: "/Use rs/mokapos/node/next-blog/node_modules/next/babel.js$0")

Finally your .babelrc pretty much would be like "test": { "presets": [["next/babel", {"preset-env": {"modules": true}}]] }

@gnapse check out the updated version of with-jest (updated earlier today), basically you need to add the bridged babel-core module, and then also have babel-jest

Also experiencing this

 ERROR  Failed to compile with 1 errors                                                                                 

 error  in ./pages/_document.jsx

Module build failed: Error: [BABEL] /Users/luke/development/code/application/web/pages/_document.jsx: .value is not a valid Plugin property

package.json

{
  "name": "application",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start",
    "test": "jest --no-cache",
    "test:debug": "jest --debug",
    "test:verbose": "jest --verbose",
    "test:watch": "jest --watch",
    "test:coverage": "jest -- --coverage --no-cache",
    "test:coverage:view": "jest -- --coverage --no-cache && open coverage/lcov-report/index.html",
    "lint": "eslint .",
    "storybook": "start-storybook -s . -p 6006",
    "build-storybook": "build-storybook",
    "analyze": "export ANALYZE=true && next"
  },
  "dependencies": {
    "classnames": "^2.2.5",
    "es6-promise": "^4.2.4",
    "isomorphic-unfetch": "^2.0.0",
    "js-cookie": "^2.2.0",
    "jsonwebtoken": "^8.2.1",
    "jss": "^9.8.1",
    "material-ui": "^1.0.0-beta.42",
    "moment": "^2.22.1",
    "next": "6.0.0",
    "next-redux-saga": "^2.0.1",
    "next-redux-wrapper": "^1.3.5",
    "prop-types": "^15.6.1",
    "react": "^16.3.2",
    "react-dom": "^16.3.2",
    "react-iframe": "^1.1.0",
    "react-jss": "^8.4.0",
    "react-popper": "^0.10.1",
    "react-redux": "^5.0.6",
    "redux": "^4.0.0",
    "redux-devtools-extension": "^2.13.2",
    "redux-form": "^7.3.0",
    "redux-saga": "^0.16.0",
    "webpack-bundle-analyzer": "^2.11.1"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0-beta.46",
    "@babel/preset-env": "^7.0.0-beta.46",
    "@storybook/addon-actions": "^3.4.3",
    "@storybook/addon-links": "^3.4.3",
    "@storybook/addon-storyshots": "^3.4.3",
    "@storybook/addons": "^3.4.3",
    "@storybook/react": "^3.4.3",
    "@zeit/next-sass": "^0.1.2",
    "babel-loader": "^8.0.0-beta.2",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "eslint": "^4.19.1",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-plugin-import": "^2.11.0",
    "eslint-plugin-jest": "^21.15.1",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.7.0",
    "jest": "^22.4.3",
    "jest-cli": "^22.4.3",
    "node-sass": "^4.9.0",
    "react-addons-test-utils": "^15.6.2",
    "react-test-renderer": "^16.3.2",
    "webpack": "^3.11.0",
    "webpack-bundle-size-analyzer": "^2.7.0"
  }
}

.babelrc

{
  "presets": [
    "next/babel",
    "@babel/preset-env"
  ]
}

next.config.js

const withSass = require('@zeit/next-sass')

module.exports = withSass({
  cssModules: true,
})
Plugin 0 specified in "/home/travis/build/GabrielDuarteM/portfolio/node_modules/next/babel.js" provided an invalid property of "default" (While processing preset: "/home/travis/build/GabrielDuarteM/portfolio/node_modules/next/babel.js")

Happened to me too, but only when running the tests (using jest).

Reproducible on https://github.com/GabrielDuarteM/portfolio, just run yarn add next to install the latest next version and run yarn test to run the tests.

The complete error log can be seen on this Travis build

yarn start and yarn build is running fine, only yarn test throws that error.

package.json

{
  "name": "portfolio",
  "version": "1.0.0",
  "main": "index.js",
  "author": "Gabriel Duarte <gabrielqduarte@gmail.com> (https://github.com/GabrielDuarteM/)",
  "license": "MIT",
  "scripts": {
    "start": "next src",
    "start:prod": "next start src -p $PORT",
    "prebuild": "rimraf src/out",
    "build": "next build src && yarn export && cp src/root/* src/out",
    "export": "next export src",
    "deploy": "yarn build && netlify deploy",
    "deploy:staging": "yarn deploy -e staging",
    "test": "jest",
    "lint": "yarn eslint src/**/*.js",
    "ci": "yarn build && yarn test && yarn lint"
  },
  "dependencies": {
    "next": "^6.0.0",
    "react": "^16.3.2",
    "react-dom": "^16.3.2"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.3",
    "babel-preset-env": "^1.6.1",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "eslint": "4.19.1",
    "eslint-config-airbnb": "16.1.0",
    "eslint-config-prettier": "^2.9.0",
    "eslint-plugin-import": "2.11.0",
    "eslint-plugin-jsx-a11y": "6.0.3",
    "eslint-plugin-prettier": "^2.6.0",
    "eslint-plugin-react": "7.7.0",
    "jest": "^22.4.3",
    "prettier": "^1.12.1",
    "rimraf": "^2.6.2",
    "sw-precache-webpack-plugin": "^0.11.5"
  }
}

.babelrc

{
  "env": {
    "production": {
      "presets": [
        [
          "env",
          {
            "modules": false,
            "useBuiltIns": true,
            "targets": {
              "browsers": "> 5%"
            }
          }
        ],
        "next/babel"
      ]
    },
    "development": {
      "presets": [
        [
          "env",
          {
            "modules": false,
            "useBuiltIns": true,
            "targets": {
              "browsers": "> 5%"
            }
          }
        ],
        "next/babel"
      ]
    },
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]]
    }
  }
}

next.config.js

const SWPrecacheWebpackPlugin = require("sw-precache-webpack-plugin")

module.exports = {
  exportPathMap: function() {
    return {
      "/": { page: "/" },
      "/about": { page: "/about" },
    }
  },
  excludeFile: str => /\*.{spec,test}.js/.test(str),
  webpack: config => {
    config.plugins.push(
      new SWPrecacheWebpackPlugin({
        verbose: true,
        staticFileGlobsIgnorePatterns: [/\.next\//],
        runtimeCaching: [
          {
            handler: "networkFirst",
            urlPattern: /^https?.*/,
          },
        ],
      }),
    )

    return config
  },
}