14

Following is my package json file. I have installed node_modules successfully. But Getting the error:

"TypeError: Cannot read property 'babel' of undefined"

while running "webpack --watch". Please let me know if anyone is aware of this.

"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",
Bram Houben
  • 180
  • 2
  • 15
Abhilasha
  • 1,177
  • 4
  • 10
  • 17

2 Answers2

17

Your version of babel-loader looks to be out of date. Uninstall it with npm uninstall babel-loader and re-install with npm i -D babel-loader. You may also need to update to babel-preset-env and remove babel-preset-es2015

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

Chad Pjontek
  • 303
  • 1
  • 7
10

For me it was a version mismatch between webpack and babel-loader.

I had babel-loader@6.2.0 with webpack@4.12.0, updating to babel-loader@7.1.4 fixed the issue for me.

Divyanshu Rawat
  • 4,421
  • 2
  • 37
  • 53