Babel - 错误:无法找到模块'babel-runtime/helpers/typeof'

jer*_*ome 12 transform typeof babeljs

通过Transpiling gulp-babel服务器和browserifybabelify客户端-使用异步和我的代码等待.这些功能似乎转变得很好,但...... Error: Cannot find module 'babel-runtime/helpers/typeof'

的内容 .babelrc

{
  "presets": ["react", "es2015"],
  "plugins": [
    "transform-class-properties",
    "transform-async-to-generator",
    "transform-runtime"
  ]
}
Run Code Online (Sandbox Code Playgroud)

相关内容 package.json

"babel-core": "6.3.13",
"babel-eslint": "4.1.6",
"babel-plugin-transform-async-to-generator": "6.3.13",
"babel-plugin-transform-class-properties": "6.3.13",
"babel-plugin-transform-runtime": "6.3.13",
"babel-preset-es2015": "6.3.13",
"babel-preset-react": "6.3.13",
"babelify": "7.2.0",
"browserify": "12.0.1",
"gulp-babel": "6.1.0",
Run Code Online (Sandbox Code Playgroud)

我已经找到了一些其他的提及,其中许多似乎在这里引领 - https://github.com/babel/babel/issues/2954

但是我在上面的链接上获得了404,实际上看不到任何与之相关的问题babel- https://github.com/babel/babel/issues重定向到https://github.com/babel/babel/pulls

有任何想法吗?

jer*_*ome 7

事实证明我需要安装babel-runtime,我认为随着Babel v6的发布而被弃用.


小智 7

我遇到了这个错误,整晚都在寻找解决方案,最后只是删除了node_modules文件夹,确实npm install有效


Tyl*_*ier 5

当我面对这个问题时,这是我的版本npm。我新安装了 Ubuntu 16.04,并且曾经nodenv使用过 Node 4.2.3,但没有从我的默认设置中更新 npm。因此使用npm update -g npm从版本2.14.7更改为3.10.5。我删除了再node_modules运行npm i,之后就没有看到错误信息了。(请注意,删除node_modules并运行npm i而不更新npm是行不通的。)


小智 5

安装 babel-helpers 解决了我的问题。npm install --save babel-helpers