鍍金池/ 問答/HTML/ vue-cli(3.0.0-beta.6)創(chuàng)建項(xiàng)目后使用yarn serve就報(bào)

vue-cli(3.0.0-beta.6)創(chuàng)建項(xiàng)目后使用yarn serve就報(bào)錯(cuò)

 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
回答
編輯回答
短嘆

"devDependencies": {

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

}

降下版本,暫時(shí)不要用新的版本。

2018年1月8日 00:05
編輯回答
茍活

github上面已經(jīng)開始有解決的方法了。點(diǎn)這里

2017年5月9日 19:02
編輯回答
懶豬

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

2018年2月18日 20:41
編輯回答
尤禮

首先vue-cli3.0目前是公測(cè)階段,個(gè)人不建議不要用于實(shí)際項(xiàng)目,等到正式版再使用!文檔里也有說明:
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.
大致意思:我們大致功能已經(jīng)開發(fā)完畢,但仍可能存在漏洞。在發(fā)布候選版(RC)之前,API也可能會(huì)改變。除非你有冒險(xiǎn)精神,否則不要在生產(chǎn)中使用。

回到您的問題,上面的已經(jīng)提供了一些解決辦法:
比如降版本,在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

更或者升級(jí)版本,在今天vue-cli發(fā)布了3.0.0-beta.7(推薦)

2017年8月25日 08:49