新建项目框架,挪用了之前跑的很好的配置,npm run dev的时候,却是各种报错,
经过一大圈实践以后,发现babel升级了一个大版本,已经到7.X了,



各种配置都不成以后,手动把所有的 7.X以前的版本,全部换成 @,最新版本,最终成功,晒出package.json文件

```json
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.2",
"babel-plugin-import": "^1.11.0",
"babel-plugin-transform-class-properties": "^6.24.1",
```
(方便复制)
以及.babelrc文件

{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
"react-hot-loader/babel",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-runtime",
"transform-class-properties",
[
"import", {
"libraryName": "antd",
"style": "css"
}
]
]
}
网友评论