nuxt: Babel "loose" option error spamming in console on fresh project
Versions
- nuxt: v2.15.4
- node: v14
Reproduction
Just make a new project on CodeSandbox and you’ll see the error.
Here is one I just made: https://codesandbox.io/s/serene-thunder-yl6rq
Steps to reproduce
- Make a new Nuxt project.
- Run it.
- Look at the console.
What is Expected?
No random warnings.
What is actually happening?
The warning…
Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties.
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
["@babel/plugin-proposal-private-methods", { "loose": true }]
to the "plugins" section of your Babel config.
…is spammed over and over again.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 57
- Comments: 41 (10 by maintainers)
Commits related to this issue
- [fix] package.json https://github.com/nuxt/nuxt.js/issues/9224 — committed to toshiki-o23/syuwakai by toshiki-o23 3 years ago
- Quickfix babel nuxt Rel : https://github.com/nuxt/nuxt.js/issues/9224 Rel : https://github.com/nuxt/nuxt.js/pull/9631/commits — committed to nte-unifr/eddb by alrick 3 years ago
With yarn, please pin your babel deps manually in your
package.json, then useyarn installagain:With npm, add these as dev deps (with the same versions).
I fixed this by adding babel setting to the build section:
to the nuxt.config.js file. It removes the warning, I do not have a clue what it does under the hood. Seems to work though.
@bhpcv252
Fixes the issue for me for time being.
This will be fixed in https://github.com/nuxt/nuxt.js/pull/9631.
Should be fixed in v.2.15.5 (PR: #9232).
You can safely revert
resolutionsinpackage.jsonandbuild.babel.pluginsinnuxt.config(and it is recommended to do so to avoid having stalled patch).In case of having same issue after upgrading to 2.15.5, please remove lock file (
yarn.lockorpackage.lock.json),node_modules/.cacheand.nuxt. If still having issues, please report here.If having a different error after upgrading, please use a new issue to report.
@pi0 , Having same issue after upgrading to 2.15.7, but found this work for me.
https://github.com/babel/babel/issues/11622#issuecomment-638609015
Thank you, it worked for my project 😊
// Build Configuration: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-build build: { babel: { plugins: [[‘@babel/plugin-proposal-private-property-in-object’, { loose: true }]], } }
In
nuxt.config.jsThanks alot. This worked
Same problem here.
@heyshadowsmith The fix has not been released yet, that’s why @pi0 reopened this issue.
Ahh im not the only one, i’m trying to update 😛 thanks guys
The warning will be fixed in https://github.com/nuxt/nuxt.js/pull/9232.
@manniL Thanks …It works fine for npm also. But shouldn’t the create-nuxt-app add those devDependencies by default while creating the project?
thnaks it also works for me
"resolutions": { "@babel/core": "7.13.15", "@babel/preset-env": "7.13.15" }It maybe worth your will to review the following article. Thanks
https://www.linkedin.com/pulse/nuxtjs-warn-though-loose-option-set-false-your-babelpreset-env-/
Thanks. This works for me!
Ah yes, victory!
Still happening for me in nuxt-edge, therefore I assume there is more work needed to fix this
Im also encounter this problem,. I was just deleted the node_modules directory, and package-lock.json,. then npm install again,… In running “npm run dev” it always shows the warning.
@pi0 @clarkdo I created a new project by running
npx create-nuxt-appjust now, and then when I rannpm run dev, I was shown this message.I ultimately fixed it by running
npm i @babel/core@7.13.15 @babel/preset-env@7.13.15, but I am unsure if #9232 squared this away unless I’m missing something.In short, this is what the Babel website says about itself:
@rickalex21 You will be in for an extremely bumpy and information dense ride. Babeljs has been part of many javascript build tooling for a very long time and therefor shouldn’t be a surprise for any frontend developer.