Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuxt js - Fresh install of nuxt 2.14.6 contains babel "loose option" warnings

I have a fresh install of nuxt version 2.14.6 and I would like to silence an error I get when I run the nuxt command:

 WARN  Though the "loose" option was set to "false" in your @babel/preset-env co
The "loose" option must be the same for @babel/plugin-proposal-class-properties,
        ["@babel/plugin-proposal-private-methods", { "loose": true }]
to the "plugins" section of your Babel config.

I'm assuming I need to override the babel config in my nuxt.config.js file, but I haven't found any helpful solutions.

like image 970
ajohnson10209 Avatar asked May 01 '21 19:05

ajohnson10209


4 Answers

Add the following to your nuxt.config.js file under the build section.

nuxt.config.js

build: {   babel:{     plugins: [       ['@babel/plugin-proposal-private-methods', { loose: true }]     ]   } } 
like image 112
Jorge Granados Avatar answered Sep 25 '22 13:09

Jorge Granados


Try add these in nuxt.config.js:

build: {   babel:{     plugins: [       ["@babel/plugin-proposal-class-properties", { "loose": true }],       ["@babel/plugin-proposal-private-methods", { "loose": true }],       ["@babel/plugin-proposal-private-property-in-object", { "loose": true }]     ]   }   }, 
like image 39
Андрей Пархоменко Avatar answered Sep 24 '22 13:09

Андрей Пархоменко


I'd rather reset nuxt back to 2.15.2 and wait until it's fixed. While the above answer fixes it in the short run, those warnings on a fresh nuxt install look like a bug to me.

like image 29
Sebastian Landwehr Avatar answered Sep 26 '22 13:09

Sebastian Landwehr


More recent update for Nuxt 2.15.7

It looks like some errors are back again with the latest release, more info can be found here Latest Nuxt v2.15.7 install with babel "loose" option warnings


This ons is fixed from Nuxt v2.15.5 as stated in this github issue: https://github.com/nuxt/nuxt.js/issues/9224#issuecomment-835742221

You can remove any resolutions and build.babel.plugins related to this bug in your nuxt.config.js configuration. Also, if needed you should reset:

  • yarn.lock (or package-lock.json)
  • node_modules/.cache
  • .nuxt
like image 25
kissu Avatar answered Sep 23 '22 13:09

kissu