JavaScript babel "TypeError: Cannot read property 'bindings' of null" when trying to transpile
JavaScript babel "TypeError: Cannot read property 'bindings' of null" when trying to transpile
使用 PhpStorm,据我所知,当我修改一个 JavaScript 源文件时,我有这个文件观察器 (babel),它会做一些魔术并且将这些文件稍微转换一下放在另一个文件夹 (dist
) 中,以便 gulp 可以 "compile" 一切,应用程序可以 运行 .但是每当我修改文件而不是魔术发生时,我都会得到
"TypeError: Cannot read property 'bindings' of null"**
我不明白为什么。
我尝试了什么:
我的老师让我修改配置,所以它是 babel.cmd 而不是 babel,因为我在 Windows,但是那没有用。
此时我几乎卸载并重新安装了所有东西,我相信一切都是最新版本。
我试图将我的 .babelrc
文件中的预设设置为 "@babel/preset-env"
,但这也不起作用。
我的 .babelrc 文件
{
"presets": ["@babel/preset-env"]
}
我的package.json文件
{
"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"
}
}
}
错误详情
我不太明白这个 "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
这是由于 6 和 7 之间的 babel 依赖项不匹配造成的。您目前似乎都安装了。
尝试从 package.json
中的依赖项中删除 babel-core
、babel-polyfill
和 babel-preset-env
。
如果您需要 babel-polyfill
,那么您应该安装版本 7 软件包,该软件包已重命名为 @babel/polyfill
。
使用 PhpStorm,据我所知,当我修改一个 JavaScript 源文件时,我有这个文件观察器 (babel),它会做一些魔术并且将这些文件稍微转换一下放在另一个文件夹 (dist
) 中,以便 gulp 可以 "compile" 一切,应用程序可以 运行 .但是每当我修改文件而不是魔术发生时,我都会得到
"TypeError: Cannot read property 'bindings' of null"**
我不明白为什么。
我尝试了什么:
我的老师让我修改配置,所以它是 babel.cmd 而不是 babel,因为我在 Windows,但是那没有用。
此时我几乎卸载并重新安装了所有东西,我相信一切都是最新版本。
我试图将我的
.babelrc
文件中的预设设置为"@babel/preset-env"
,但这也不起作用。
我的 .babelrc 文件
{
"presets": ["@babel/preset-env"]
}
我的package.json文件
{
"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"
}
}
}
错误详情
我不太明白这个 "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
这是由于 6 和 7 之间的 babel 依赖项不匹配造成的。您目前似乎都安装了。
尝试从 package.json
中的依赖项中删除 babel-core
、babel-polyfill
和 babel-preset-env
。
如果您需要 babel-polyfill
,那么您应该安装版本 7 软件包,该软件包已重命名为 @babel/polyfill
。