vue-cli(3.0.0-beta.6)创建项目后使用yarn serve就报错

 ERROR  Failed to compile with 1 errors                                                                                                                                   14:33:04

 error  in ./src/main.js

Module build failed: Error: [BABEL] /Users/zhangwei/Company/Qtay/迅聘/xfind-web/src/main.js: The new decorators proposal is not supported yet. You must pass the `"decoratorsLegacy": true` option to @babel/preset-stage-2 (While processing: "/Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@vue/babel-preset-app/index.js$1")
    at /Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@babel/preset-stage-2/lib/index.js:107:11
    at /Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@babel/helper-plugin-utils/lib/index.js:18:12
    at /Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@babel/core/lib/config/full.js:172:14
    at cachedFunction (/Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@babel/core/lib/config/caching.js:42:17)
    at loadPresetDescriptor (/Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@babel/core/lib/config/full.js:243:63)
    at /Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@babel/core/lib/config/full.js:68:19
    at Array.map (<anonymous>)
    at recurseDescriptors (/Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@babel/core/lib/config/full.js:66:36)
    at recurseDescriptors (/Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@babel/core/lib/config/full.js:97:26)
    at loadFullConfig (/Users/zhangwei/Company/Qtay/迅聘/xfind-web/node_modules/@babel/core/lib/config/full.js:112:6)

 @ multi (webpack)-dev-server/client/index.js (webpack)/hot/dev-server.js ./src/main.js
阅读 8.7k
4 个回答

首先vue-cli3.0目前是公测阶段,个人不建议不要用于实际项目,等到正式版再使用!文档里也有说明:
Most of the planned features are in place but there may still be bugs. API may still change until we reach RC phase. Do not use in production yet unless you are adventurous.
大致意思:我们大致功能已经开发完毕,但仍可能存在漏洞。在发布候选版(RC)之前,API也可能会改变。除非你有冒险精神,否则不要在生产中使用。

回到您的问题,上面的已经提供了一些解决办法:
比如降版本,在package.json里面的devDependencies添加@babel/preset-stage-2 :

"devDependencies": {
    "@babel/preset-stage-2": "7.0.0-beta.44",
    ...
}

或者github的其他解决方案:npm run serve error: You must pass the "decoratorsLegacy": true option to @babel/preset-stage-2

更或者升级版本,在今天vue-cli发布了3.0.0-beta.7(推荐)

github上面已经开始有解决的方法了。点这里

在package.json里面的devDependencies添加 "devDependencies": {
"@babel/preset-stage-2": "7.0.0-beta.44",
...
}

"devDependencies": {

"autoprefixer": "^8.3.0",
"@babel/preset-stage-2": "7.0.0-beta.45",

}

降下版本,暂时不要用新的版本。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏