Babel - Error: Cannot find module 'babel-runtime/helpers/typeof'
Babel - Error: Cannot find module 'babel-runtime/helpers/typeof'
服务器通过 gulp-babel
传输,客户端通过 browserify
传输 babelify
- 在我的代码中使用异步和等待。这些功能似乎可以很好地转换,但是......
Error: Cannot find module 'babel-runtime/helpers/typeof'
.babelrc
的内容
{
"presets": ["react", "es2015"],
"plugins": [
"transform-class-properties",
"transform-async-to-generator",
"transform-runtime"
]
}
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",
我发现了其他一些提及,其中很多似乎都指向这里 - https://github.com/babel/babel/issues/2954
但我在上面的 link 处收到 404,确实看不到与 babel
- https://github.com/babel/babel/issues redirects to https://github.com/babel/babel/pulls
相关的任何问题
有什么想法吗?
结果我需要安装 babel-runtime
,我认为它已随着 Babel v6 的发布而被弃用。
看起来他们已将所有问题迁移到另一个系统:https://phabricator.babeljs.io/T2954
我遇到了类似的问题:
error in cannot find module 'babel-runtime/helpers/interop-require-default'
我的处理方式是:
- 删除node_modules文件夹
- 重新
npm install
,这次成功了
我遇到了这个错误,整晚都在寻找解决方案,最后只是删除了 node_modules
文件夹,npm install
成功了
当我面对这个时,这是我的 npm
版本。我新安装了 Ubuntu 16.04 并使用 nodenv
使节点 4.2.3 运行,但没有从我拥有的任何默认值更新 npm。因此使用 npm update -g npm
从版本 2.14.7 更改为 3.10.5。我又删了node_modules
和运行npm i
,之后就没看到报错信息了。 (请注意,删除 node_modules
和 运行 npm i
而不更新 npm
无效。)
我或多或少有过类似的错误
“找不到模块 'babel-generator'。不知道如何调试它们。所以我最终决定
删除节点模块,有时(windows'del node_modules'命令没有删除node_modules)那样的话,手动删除它们。
npm 缓存清理 --force
npm 缓存清除 --force
npm prune
npm 安装
这种方法对我有用。
安装 babel-helpers 解决了我的问题。
npm install --save babel-helpers
在我的例子中,我不得不在 webpack 中排除 node_modules:
{
test: /\.m?js$/,
include: [/svelte/],
use: [babelLoader],
exclude: /node_modules/
},
出于某种原因,没有它,它正在为另一个项目工作,而不是为新项目工作。
PS: 我先尝试了上面的所有解决方案,但没有成功。
我在使用 CRA 时 运行 遇到了类似的问题。
以下是让我着迷的步骤 ;)。
1 - rm -rf node_modules
2 - rm package-lock.json
3 - npm install
服务器通过 gulp-babel
传输,客户端通过 browserify
传输 babelify
- 在我的代码中使用异步和等待。这些功能似乎可以很好地转换,但是......
Error: Cannot find module 'babel-runtime/helpers/typeof'
.babelrc
{
"presets": ["react", "es2015"],
"plugins": [
"transform-class-properties",
"transform-async-to-generator",
"transform-runtime"
]
}
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",
我发现了其他一些提及,其中很多似乎都指向这里 - https://github.com/babel/babel/issues/2954
但我在上面的 link 处收到 404,确实看不到与 babel
- https://github.com/babel/babel/issues redirects to https://github.com/babel/babel/pulls
有什么想法吗?
结果我需要安装 babel-runtime
,我认为它已随着 Babel v6 的发布而被弃用。
看起来他们已将所有问题迁移到另一个系统:https://phabricator.babeljs.io/T2954
我遇到了类似的问题:
error in cannot find module 'babel-runtime/helpers/interop-require-default'
我的处理方式是:
- 删除node_modules文件夹
- 重新
npm install
,这次成功了
我遇到了这个错误,整晚都在寻找解决方案,最后只是删除了 node_modules
文件夹,npm install
成功了
当我面对这个时,这是我的 npm
版本。我新安装了 Ubuntu 16.04 并使用 nodenv
使节点 4.2.3 运行,但没有从我拥有的任何默认值更新 npm。因此使用 npm update -g npm
从版本 2.14.7 更改为 3.10.5。我又删了node_modules
和运行npm i
,之后就没看到报错信息了。 (请注意,删除 node_modules
和 运行 npm i
而不更新 npm
无效。)
我或多或少有过类似的错误
“找不到模块 'babel-generator'。不知道如何调试它们。所以我最终决定
删除节点模块,有时(windows'del node_modules'命令没有删除node_modules)那样的话,手动删除它们。
npm 缓存清理 --force
npm 缓存清除 --force
npm prune
npm 安装
这种方法对我有用。
安装 babel-helpers 解决了我的问题。 npm install --save babel-helpers
在我的例子中,我不得不在 webpack 中排除 node_modules:
{
test: /\.m?js$/,
include: [/svelte/],
use: [babelLoader],
exclude: /node_modules/
},
出于某种原因,没有它,它正在为另一个项目工作,而不是为新项目工作。
PS: 我先尝试了上面的所有解决方案,但没有成功。
我在使用 CRA 时 运行 遇到了类似的问题。
以下是让我着迷的步骤 ;)。
1 - rm -rf node_modules
2 - rm package-lock.json
3 - npm install