Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript babel "TypeError: Cannot read property 'bindings' of null" when trying to transpile

Using PhpStorm, as I understand it, when I modify a JavaScript source file, I have this filewatcher (babel) that will do some kind of magic and places these files a little transformed in another folder (dist) so that gulp can "compile" everything and the application can be run. But whenever I modify a file instead of the magic happening I get a

"TypeError: Cannot read property 'bindings' of null"**

I don't understand why.

What I tried:

  • My teacher told me to modify the configuration so that it's babel.cmd and not babel because I'm on Windows, but that didn't work.

  • I pretty much uninstalled and re-installed everything at this point and everything is up to the latest version i believe.

  • I tried to set the preset in my .babelrc file to "@babel/preset-env" but that didn't work either.

My .babelrc file

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

My package.json file

{
  "name": "battleship",
  "version": "0.0.1",
  "devDependencies": {
    "@babel/cli": "^7.4.4",
    "@babel/core": "^7.4.4",
    "@babel/preset-env": "^7.4.4",
    "babel-jest": "^24.8.0",
    "babel-loader": "^7.1.5",
    "babel-preset-env": "1.6.1",
    "gulp": "^4.0.2",
    "jest": "^24.8.0",
    "tar": "^4.4.8"
  },
  "scripts": {
    "test": "jest"
  },
  "dependencies": {
    "babel-core": "^6.26.3",
    "babel-polyfill": "6.26.0",
    "browserify": "16.1.1",
    "core-js": "^3.0.1",
    "fstream": "^1.0.12",
    "glob": "7.1.2",
    "md5": "2.2.1",
    "npm": "^6.9.0",
    "vinyl-source-stream": "2.0.0",
    "webpack": "^2.7.0"
  },
  "jest": {
    "browser": true,
    "modulePathIgnorePatterns": [
      "<rootDir>/js/__mocks__"
    ],
    "setupFiles": [
      "./setup-jest.js"
    ],
    "transform": {
      "^.+\\.jsx?$": "babel-jest"
    }
  }
}

Detail of the error

I don't really understand what this "bindings" property refers to and what i'm supposed to change about it, I didn't code in any property called bindings..

cmd.exe /D /C call C:\Users\lande\Documents\js_Battleship\node_modules\.bin\babel.cmd js\controllers\StatController.js --out-dir dist --source-maps --presets env
TypeError: Cannot read property 'bindings' of null
    at Scope.moveBindingTo (C:\Users\lande\Documents\js_Battleship\node_modules\@babel\traverse\lib\scope\index.js:864:13)
    at convertBlockScopedToVar (C:\Users\lande\Documents\js_Battleship\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:139:13)
    at PluginPass.VariableDeclaration (C:\Users\lande\Documents\js_Battleship\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:26:9)
    at newFn (C:\Users\lande\Documents\js_Battleship\node_modules\@babel\traverse\lib\visitors.js:193:21)
    at NodePath._call (C:\Users\lande\Documents\js_Battleship\node_modules\@babel\traverse\lib\path\context.js:53:20)
    at NodePath.call (C:\Users\lande\Documents\js_Battleship\node_modules\@babel\traverse\lib\path\context.js:40:17)
    at NodePath.visit (C:\Users\lande\Documents\js_Battleship\node_modules\@babel\traverse\lib\path\context.js:88:12)
    at TraversalContext.visitQueue (C:\Users\lande\Documents\js_Battleship\node_modules\@babel\traverse\lib\context.js:118:16)
    at TraversalContext.visitQueue (C:\Users\lande\Documents\js_Battleship\node_modules\@babel\traverse\lib\context.js:124:21)
    at TraversalContext.visitQueue (C:\Users\lande\Documents\js_Battleship\node_modules\@babel\traverse\lib\context.js:124:21)

Process finished with exit code 1
like image 205
L. Landenne Avatar asked Sep 13 '25 12:09

L. Landenne


1 Answers

This is caused by a mismatch of babel dependencies between 6 & 7. You currently seem to have both installed.

Try removing babel-core, babel-polyfill and babel-preset-env from your dependencies in package.json.

If you need babel-polyfill then you should install the version 7 package instead, which has been renamed to @babel/polyfill.

like image 156
braza Avatar answered Sep 15 '25 02:09

braza