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
- fix(build): rollback to next@^5 until zeit/next.js#4227 gets fixed — committed to GabeDuarteM/portfolio by GabeDuarteM 9 years ago
- Use custom Babel loader to avoid using separate Babel copies for loader and loader options (#4417) This resolves the > .value is not a valid Plugin property error showing up for people in https... — committed to dcalhoun/next.js by loganfsmyth 8 years ago
- Make babel-core a peerDependency. Support Babel 7. (#512) Fixes #495. As of now babel is included within this project, which makes it hard for users to define the babel version they want to use. T... — committed to kulshekhar/ts-jest by joaovieira 8 years ago
- Upgrade with-jest-typescript example to next 6.0.0 (#4543) Hello! I ran into an issue using typescript and jest with next 6.0.0. I was able to work through fixing it and I wanted to share my solution... — committed to vercel/next.js by ngauthier 8 years ago
- Upgrade gh-pages example to next 6.0.3 (#4575) Hello! I have got an error while building [gh-pages example](https://github.com/zeit/next.js/tree/canary/examples/gh-pages) with next 6.0.3. I have foun... — committed to vercel/next.js by teleginzhenya 8 years ago
- Use custom Babel loader to avoid using separate Babel copies for loader and loader options (#4417) This resolves the > .value is not a valid Plugin property error showing up for people in https... — committed to lependu/next.js by loganfsmyth 8 years ago
- Upgrade with-jest-typescript example to next 6.0.0 (#4543) Hello! I ran into an issue using typescript and jest with next 6.0.0. I was able to work through fixing it and I wanted to share my solution... — committed to lependu/next.js by ngauthier 8 years ago
- Upgrade gh-pages example to next 6.0.3 (#4575) Hello! I have got an error while building [gh-pages example](https://github.com/zeit/next.js/tree/canary/examples/gh-pages) with next 6.0.3. I have foun... — committed to lependu/next.js by teleginzhenya 8 years ago
I have this exact same issue with Babel and Next.
@GabrielDuarteM to fix
babel-jestinstall:"babel-core": "7.0.0-bridge.0"npm i babel-loader@7 --save-devfixed 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:
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 propertyin development mode with a custom (express) server. Tried all the suggestions here with no success 😦So I forced
beta42deps, nukednode_modulesand usedyarninstead ofnpm(v6), and it’s working fine again. W-T-F.There is sth wrong with npm deps resolution.
I’ve had the same problem since https://github.com/zeit/next.js/releases/tag/6.0.0-canary.3
@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
devDependencies + start script
For the people getting the
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
As mentioned above, you are using a combination of Babel 6 and Babel 7.
As for
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:
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:
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.
To test running in browser with webpack: NODE_ENV=development npx node index or NODE_ENV=development npx next
NODE_ENV=production BABEL_ENV=test npx jest – that is to test using jest
package.json parts:
Later in package.json setup jest:
next.config.js
And .babelrc.js
next@6.0.0 uses 7.0.0-beta.42.
From my debugging it seems that the
babel-loaderin 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
.valuebeing 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#createConfigItemis used to create the ConfigItems.Maybe the version differences are responsible as @ewagstaff observed? Maybe there were changes made to the
createConfigItemapi?…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
createConfigItemthe error also disappears:My best guess is…
The issue is probably caused by a change to the
createConfigItemapi from 42 -> 46, or perhaps@babel/coreis being used as a singleton and storing the cached config, which the other instance of@babel/corecannot access.Maybe @loganfsmyth can shed some light?
So lets first start with explaining that you should never add
@babel/preset-envorbabel-preset-envto your.babelrc, since it breaks code splitting with webpack.Instead you can provide options to
next/babel:Also when providing options don’t set
modules: truesince 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-jestexample in this very repo:Here’s the output for that last command:
However,
yarn devworks flawlessly.There’s 2 options:
you don’t, there’s really no need to transpile it if you’re using the custom server correctly (just implementing routing / caching)
you put the server into a separate directory
serveradd aserver/.babelrcand let babel compile using that.I am also getting that error:
_document.js: .value is not a valid Plugin propertyIt 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):
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
envin your .babelrc, you should put all config insideenv, and duplicate the config for each environment (except for the differences of course). For example, here’s mine:Yes, it’s ugly, but it works.
facing same issue, babelrc
dependencies (from package.json)
error
For me the solution was to install babel-loader@7. I inspected the
@babel/core/lib/config/validation/plugins.jsmodule and the value coming into L86 was very off.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: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.
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 updatebabel-plugin-transform-defineto 1.3.0@joaovieira thanks for your response. i changed my project, but the tests are failing when i am using JavaScript variables in the styles.
like
my test-presets:
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:
node_modulesyarnoryarn installnode server/index.jsgave me the error:Replacing step 2 with
npm installenabled 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
yarnto 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
We use
instanceof ConfigItemso 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-coreto the supported version which is7.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 soInvariant 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
package.json
.babelrc
next.config.js
Happened to me too, but only when running the tests (using
jest).Reproducible on https://github.com/GabrielDuarteM/portfolio, just run
yarn add nextto install the latestnextversion and runyarn testto run the tests.The complete error log can be seen on this Travis build
yarn startandyarn buildis running fine, onlyyarn testthrows that error.package.json
.babelrc
next.config.js