Node.js 巴别塔错误:“;错误:找不到模块';巴贝尔插件转换对象静止排列';从'/流浪汉'&引用;
我正在尝试从巴别塔6->7升级。我使用了Node.js 巴别塔错误:“;错误:找不到模块';巴贝尔插件转换对象静止排列';从'/流浪汉'&引用;,node.js,npm,babeljs,Node.js,Npm,Babeljs,我正在尝试从巴别塔6->7升级。我使用了npxbabel升级--write来帮助更新package.json,然后运行了npm安装 尝试运行我们的webpack dev服务器时,它无法编译,出现以下错误: ERROR in ./src/app/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-plugin-transform-
npxbabel升级--write
来帮助更新package.json
,然后运行了npm安装
尝试运行我们的webpack dev服务器时,它无法编译,出现以下错误:
ERROR in ./src/app/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'babel-plugin-transform-object-rest-spread' from '/vagrant'
at Function.module.exports [as sync] (/vagrant/node_modules/resolve/lib/sync.js:58:15)
at resolveStandardizedName (/vagrant/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
at resolvePlugin (/vagrant/node_modules/@babel/core/lib/config/files/plugins.js:54:10)
at loadPlugin (/vagrant/node_modules/@babel/core/lib/config/files/plugins.js:62:20)
at createDescriptor (/vagrant/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
at items.map (/vagrant/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)
at Array.map (<anonymous>)
at createDescriptors (/vagrant/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
at createPluginDescriptors (/vagrant/node_modules/@babel/core/lib/config/config-descriptors.js:105:10)
at alias (/vagrant/node_modules/@babel/core/lib/config/config-descriptors.js:63:49)
.babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread"
]
}
编辑:我无法确定问题的原因,已恢复到Babel 6。有此问题,经过一些挖掘后能够解决--
在我们的网页包配置和
包.json中的插件中仍然有一个转换对象rest spread
,没有babel前缀。用@babel/plugin提案对象rest-spread替换它
为我们修复了它 @babel/plugin提案对象rest-spread
和巴贝尔插件转换对象rest-spread
之间有一个不幸的区别。我理解它们是不同的,但似乎巴贝尔7不再支持巴贝尔插件转换对象rest-spread
。替代方案是什么?还是我错了?你没有错。一个好的解决方案是将所有依赖项转换为Babel7
。最简单的解决方案是安装缺失的所有设备,并一直尝试直到其正常工作为止”_(ツ)_/''我认为可能是这样。不幸的是,有10多个软件包依赖它,所以这不是一项小任务。谢谢@Aviad。尝试使用why
或npm等效工具来理解为什么要包含它
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread"
]
}