如何解决babel依赖关系?

时间:2018-10-30 05:07:06

标签: reactjs webpack babel babel-loader

./ClientApp/Client.js中的

错误 模块构建失败(来自./node_modules/babel-loader/lib/index.js):

错误:插件/预设文件不允许导出对象,只能导出功能。

{
  "name": "misreact",
  "version": "1.0.0",
  "description": "",
  "path": "^0.12.7",
  "main": "HelloWorld.js",
  "dependencies": {
     "@babel/core": "^7.1.2",
     "babel-preset-env": "^1.7.0",
     "babel-preset-react": "^6.24.1",
     "babel-preset-stage-2": "^6.24.1",
     "react": "^16.6.0",
     "react-dom": "^16.6.0",
     "webpack": "^4.23.1",
     "webpack-cli": "^3.1.2"
   },
  "devDependencies": {
     "babel-core": "^6.26.3",
     "babel-loader": "^8.0.4",
     "webpack-dev-server": "^3.1.10"
   },
  "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
     "start:dev": "webpack-dev-server --hot"
   },
  "author": "",
  "license": "ISC"
 }

1 个答案:

答案 0 :(得分:0)

从Babel 7开始,不推荐使用阶段。您可以使用以下软件包自动更新(以下命令将在您的计算机上永久安装babel-update来运行更新):

npx babel-upgrade --write

此软件包将安装所有第二阶段更新(每个更新现在是一个单独的软件包)。您可能需要考虑实际需要哪些更新,然后删除其余的更新。

我也将升级到@ babel / env和@ babel / preset-react,如评论中所述。