本文介绍了模块构建失败(来自./node_modules/babel-loader/lib/index.js):TypeError:无法读取null的属性"bindings"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建项目时出现错误:

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

我的开发环境如下:

节点:8.0.0
npm:5.0.0

Node: 8.0.0
npm: 5.0.0

devDependencies

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

推荐答案

[email protected] 使用Babel 7.x,即@babel/core@^7.0.0,更重要的是,在您的情况下,@babel/preset-env@7代替了babel-preset-env@^1.7.0.

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

您需要确保这样做

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

并使用类似的

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

注意:对于其他遇到此问题的人,问题还可能是您正在Babel 7上使用Babel 6的插件/预设.这可能很难注意到,如果您使用的是第三方Babel预设,因为预设的版本可能与Babel本身的版本不匹配.

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.

这篇关于模块构建失败(来自./node_modules/babel-loader/lib/index.js):TypeError:无法读取null的属性"bindings"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:20