vue-cli: npm run serve error: You must pass the `"decoratorsLegacy": true` option to @babel/preset-stage-2
Version
3.0.0-beta.6
Reproduction link
Steps to reproduce
- Vue CLI v3.0.0-beta.6
- ? Please pick a preset: Manually select features
- ? Check the features needed for your project: TS, Router, Vuex, CSS Pre-processors, Linter
- ? Use class-style component syntax? Yes
- ? Use Babel alongside TypeScript for auto-detected polyfills? Yes
- ? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): LESS
- ? Pick a linter / formatter config: Airbnb
- ? Pick additional lint features:
- ? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In dedicated config files
- ? Save this as a preset for future projects? No
vue-cli will install @babel/preset-stage-2@7.0.0-beta.45 and npm run serve will throw error:
The new decorators proposal is not supported yet. You must pass the “decoratorsLegacy”: true option to @babel/preset-stage-2
see: https://github.com/babel/babel/blob/master/packages/babel-preset-stage-2/src/index.js#L29
forgive my poor English
What is expected?
server success
What is actually happening?
The new decorators proposal is not supported yet. You must pass the "decoratorsLegacy": true option to @babel/preset-stage-2
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 65
- Comments: 26 (1 by maintainers)
Commits related to this issue
- Add "decoratorsLegacy" to presets — committed to babel/babel by nicolo-ribaudo 6 years ago
I had solved the problem by using a custom config by
@babel/preset-envin file .babelrc. Working well, like this:Guys while this issue is not fixed, simply use this temporary solution: Specify the old version of
@babel/preset-stage-2indevDependenciesthen run
npm run installMy working file of
added line 21: decoratorsLegacy: options.decoratorsLegacy || false and line 42 : decoratorsLegacy: true
missed another part need to change line number : 40 set decoratorsLegacy to true
fix? i am waiting
Installing
babel-preset-stage-2@7.0.0-beta.44per https://github.com/vuejs/vue-cli/issues/1162#issuecomment-383797149 did not resolve the error for me. The other suggestion in https://github.com/vuejs/vue-cli/issues/1162#issuecomment-383796325 actually worked, but I discovered a different solution that modifies the@vue/apppreset to include the requireddecoratorsLegacysetting:.babelrc(which only contains a config to use the@vue/apppreset)..babelrc.jswith the following code:This solution works better in my opinion because it maintains the settings originally intended by
@vue/app, and should be forward compatible with any potential changes in@vue/app(assuming no conflict with a newdecoratorsLegacysetting). [1]While those PR changes are discussed
vue createis broken for the entire community, and I’d expect some existing projects are broken if they lose their lockfile as well.Maybe there should a hard lock onto the previous beta version of babel rather than a
^to prevent this from happening again.Edit: Confirmed, just talked to the babel maintainers who say that you should absolutely version lock your babel betas. babel/babel@2679d67
Waiting!
Same. On a fresh install, using
5.8.0package.json
Really sorry this happened!
We aren’t in RC yet and there has been a few things we wanted to change before doing so. Unfortunately, this means that a project that is using
^would pick up the latest beta. And this isn’t specific to this release or even this project since at some point you might hit an intentional breaking change. The internal packages are also exact versions as well; this can be an issue in a monorepo.Not really sure a better way to be able to talk/enforce this on our side. I think we’ve said this per release, but it hasn’t broken in such an obvious way for people before?
Here’s Babel’s own deps for Babel https://github.com/babel/babel/blob/3a2aa9b86284957533d01105754044fb6b235d41/package.json#L13-L15.
I’m using beta7 and still had the issue, until I deleted and reinstalled node mods
https://github.com/vuejs/vue-cli/issues/1162#issuecomment-383797149 worked for me.
Just to clarify, you’ll want to add this the
@babel/preset-stage-2line in yourpackage.jsonsitting in the root of your project. There is not currently an entry for that package in there and that threw me off. Don’t forget to runnpm installafter you updatepackage.jsonAs babel added “decoratorsLegacy” to presets few days ago https://github.com/babel/babel/commit/2679d6775cc957e6cc77f23da0e31cd24bbfd18f
I changed vue/babel-preset-app/index.js (line number: 17)
const envOptions = { modules: options.modules || false, targets: options.targets, useBuiltIns: typeof options.useBuiltIns === 'undefined' ? 'usage' : options.useBuiltIns, }added decoratorsLegacyconst envOptions = { modules: options.modules || false, targets: options.targets, useBuiltIns: typeof options.useBuiltIns === 'undefined' ? 'usage' : options.useBuiltIns, decoratorsLegacy: options.decoratorsLegacy || false }It works, not sure whether it is best way thoughthere is a new cli version published (beta7) that fixes this issue. This issue can be closed now.
One of my colleague have this error … Mine is resolve
error in ./src/App.vue Module build failed: TypeError: Property right of AssignmentExpression expected node to be of a type ["Expression"] but instead got nulladding to
.babelrcis not helping. The same is for just using the fixed version ofpreset-stage-2, and both in combination. Hopefully the next beta will be out soon and this issue addressed as well. Hacking the code innode_modules/is no solution.Waiting for https://github.com/vuejs/vue-cli/pull/1163 to be merged.
I don’t have any error with your dependancies on a clean folder. Try clearing your
node_modulesfolder ? You might have installed a package which is conflicting with the script and not saved to yourpackage.json@Hugale12 : Did you try https://github.com/vuejs/vue-cli/issues/1162#issuecomment-383797149 ? You need to run
npm installafter the change.Waiting for what ? It’s a beta of vue-cli, and multiple way to fix the issue has been given, just use them ?