TypeError:无法读取未定义的属性'babel'

Abh*_*sha 5 babel npm node-modules webpack vue.js

以下是我的包json文件.我已经成功安装了node_modules.但得到错误:

"TypeError:无法读取未定义的属性'babel'"

在运行"webpack --watch"时.如果有人知道这一点,请告诉我.

"axios": "0.16.2",
"babel-plugin-root-import": "^5.1.0",
"bootstrap": "3.3.7",
"chalk": "^2.3.0",
"chart.js": "^2.7.1",
"del": "^3.0.0",
"html-entities": "^1.2.1",
"jquery": "3.1.1",
"karma-es6-shim": "^1.0.0",
"leaflet": "1.0.*",
"less": "2.7.2",
"libphonenumber-js": "^1.2.12",
"lodash": "4.17.4",
"moment": "^2.19.1",
"store": "^2.0.12",
"url-loader": "0.5.8",
"vee-validate": "2.0.0-rc.7",
"vue": "2.4.2",
"vue-chartjs": "^2.7.2",
"vue-loader": "12.0.3",
"vue-paginate": "3.4.0",
"vue-resource": "1.2.1",
"vue-router": "2.3.1",
"vue-template-compiler": "2.4.2",
"vuejs-datepicker": "0.6.3",
"vuex": "^2.5.0"


 },
  "devDependencies": {
    "babel-cli": "6.23.0",
    "babel-core": "6.23.1",
    "babel-loader": "6.3.2",
    "babel-preset-es2015": "6.22.0",
Run Code Online (Sandbox Code Playgroud)

小智 10

你的babel-loader版本看起来已经过时了.卸载npm uninstall babel-loader并重新安装npm i -D babel-loader.您可能还需要更新babel-preset-env和删除babel-preset-es2015

https://babeljs.io/docs/en/env/#upgrading-to-babel-preset-env


Div*_*wat 7

对我来说,这是webpackbabel-loader之间的版本不匹配。

我只好babel-loader@6.2.0webpack@4.12.0,更新到babel-loader@7.1.4固定的问题对我来说。