巴扎黑2017-04-17 16:33:03
你看看有沒有 .babelrc 這個文件,是不是你把這個文件給忘了。
另外 .babelrc 檔案中要有react外掛。
先npm install babel-plugin-import babel-plugin-react-transform --save-p
然後 .babelrc 中至少要有這些:("stage-0"可選)
{
"presets": ["react", "es2015", "stage-0"]
//... 其他东西
}
其實你也可以多裝一些,像是在package.json中的devDependencies加上這些
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"babel-plugin-import": "^1.1.1",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.12.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.22.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.22.0",
"babel-runtime": "^6.11.6",
再npm install一定能解決問題