Module build failed (from ./node_modules/babel-loader/lib/index.js): TypeError: Cannot read property 'bindings' of null

51,149

Solution 1

[email protected] uses Babel 7.x, which is @babel/core@^7.0.0, and more importantly in your case @babel/preset-env@7 replaces babel-preset-env@^1.7.0.

You'll need to make sure to do

npm install @babel/core @babel/preset-env

and update your Babel config to use @babel/preset-env instead of babel-preset-env with something like

"presets": [
  "@babel/preset-env"
]

Note: For others coming across this, the issue may also be that you're using plugins/preset from Babel 6 on Babel 7. This may be hard to notice if you're using a third-party Babel preset since the versions of the presets may not match the version of Babel itself.

Solution 2

The error can show with this message too:

ERROR in ./resources/js/app.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module './src/data'

I'm fixed it, with:

package.json

"devDependencies": {
    "@babel/core": "^7.7.4",
    "@babel/preset-env": "^7.7.4",

or using: npm install -D babel-loader @babel/core @babel/preset-env

Obs.: I didn't need to create a .babelrc file, to configure preset.

Share:
51,149

Related videos on Youtube

jini
Author by

jini

🦄👩🏻‍💻🐠🧐🥨📚

Updated on September 09, 2020

Comments

  • jini
    jini over 3 years

    I've got an error while building a project:

    Module build failed (from ./node_modules/babel-loader/lib/index.js):
    TypeError: Cannot read property 'bindings' of null
    

    enter image description here

    My development environment is as follows:

    Node: 8.0.0
    npm: 5.0.0

    devDependencies

    "devDependencies": {
        "babel-core": "^6.26.3",
        "babel-loader": "^8.0.0",
        "babel-preset-env": "^1.7.0",
        "webpack": "^4.17.1",
        "webpack-dev-server": "^3.1.7"
    }
    
  • Greg K
    Greg K over 5 years
    I encountered this issue, I had done the above but found removing airbnb from my presets in .babelrc remedied the issue (obviously not compatible with v7).
  • Alexandr Kazakov
    Alexandr Kazakov over 3 years
    I had the settings in gulpfile.js and so I didn't notice them for a long time.