Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
667 views
in Technique[技术] by (71.8m points)

babeljs - Latest Nuxt v2.15.7 install with babel "loose" option warnings

I've created a brand new project with npx create-nuxt-app my-cool-project but I do have some errors when running yarn dev.

Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-property-in-object since the "loose" mode option was set to "true" for @babel/plugin-proposal-private-methods. 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-property-in-object", { "loose": true }] to the "plugins" section of your Babel config.

Do you have any idea about this one? It reminds me of this other issue: Nuxt js - Fresh install of nuxt 2.14.6 contains babel "loose option" warnings

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This issue is indeed back as shown in this Github issue

https://github.com/nuxt/nuxt.js/issues/9224#issuecomment-893263501

This happens if your Nuxt version is between 2.15.5 and 2.15.7 (I think).

A temporary solution could be adding this to your nuxt.config.js file, as suggested here

build: {
  babel: {
    plugins: [
      '@babel/plugin-proposal-class-properties',
      '@babel/plugin-proposal-private-methods',

      // or with JUST the line below 
      ['@babel/plugin-proposal-private-property-in-object', { loose: true }]
    ],
  },
}

A definitive fix will probably be shipped shortly, feel free to subscribe to the Github issue to be notified of the latest updates.


EDIT: This will be fixed once this PR is merged and there's a new release: https://github.com/nuxt/nuxt.js/pull/9631


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...