JavaScript babel"TypeError:无法读取null的属性'bindings'"试图转运时 [英] JavaScript babel "TypeError: Cannot read property 'bindings' of null" when trying to transpile

查看:169
本文介绍了JavaScript babel"TypeError:无法读取null的属性'bindings'"试图转运时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,使用PhpStorm,当我修改JavaScript源文件时,我有一个文件监视程序( babel ),该文件监视程序会做一些魔术,并将这些文件稍微转换一下后放在另一个文件夹中(dist),以便 gulp 可以编译"所有内容,并且可以运行该应用程序.但是每当我修改文件而不是发生魔术时,我都会得到

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:无法读取null的属性'bindings'" **

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

我不明白为什么.

  • 我的老师告诉我修改配置,以便它是babel.cmd而不是babel,因为我在Windows上,但这没用.

  • 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.

我试图将.babelrc文件中的预设设置为"@babel/preset-env",但这也不起作用.

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

{
  "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"
    }
  }
}

错误的详细信息

我真的不明白这个绑定"属性指的是什么,我应该对此进行更改,我没有在任何称为绑定的属性中进行编码.

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

推荐答案

这是由于6和6之间的babel依赖项不匹配引起的. 7.您目前似乎已经安装了这两者.

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

尝试从package.json中的依赖项中删除babel-corebabel-polyfillbabel-preset-env.

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

如果需要babel-polyfill,则应该安装版本7软件包,该软件包已重命名为@babel/polyfill.

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

这篇关于JavaScript babel"TypeError:无法读取null的属性'bindings'"试图转运时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆