如何升级到Babel 7 [英] How to upgrade to babel 7
问题描述
我尝试将Webpack和babel分别升级到4、7,但是无法正常工作.另外,官方文档对升级没有太大帮助
I tried to upgrade Webpack and babel to 4, 7 respectively but couldn’t make it work. Also the official doc isn’t helping much with the upgrade
我正在关注问题
编译器错误:找不到模块'@ babel/core'@ multi中的错误 主要
compiler error: ERROR in Cannot find module '@babel/core' @ multi main
我正在使用的依赖项:
"babel-core": "^6.26.3",
"babel-eslint": "^9.0.0",
"babel-loader": "^8.0.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"webpack": "^4.15.0",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4"
如果需要更多详细信息,请告诉我.
Please let me know if more details required.
推荐答案
Babel changed the name of the module babel-core
to @babel/core. Just run npm install @babel/core
. This will install the latest version of Babel core.
Babel中的大多数软件包都已重命名,以遵循@babel/PACKAGE_NAME
模式.因此,如果要升级,请更改软件包名称以遵循模式并运行npm install
.
Most of the packages in Babel has been renamed to follow the pattern @babel/PACKAGE_NAME
. So if you want to upgrade, change the package names to follow the pattern and run npm install
.
要升级到Babel 7,可以使用此迁移指南.
To upgrade to Babel 7 you can use this migration guide.
这篇关于如何升级到Babel 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!