小编jar*_*hur的帖子

Babel 错误:“错误:无法从‘/vagrant’找到模块‘babel-plugin-transform-object-rest-spread’”

我正在尝试从 Babel 6 -> 7 升级。我曾经npx babel-upgrade --write协助更新package.json,然后运行了npm install.

当尝试运行我们的 webpack 开发服务器时,它无法编译并出现以下错误:

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)
Run Code Online (Sandbox Code Playgroud)

注意/vagrant是项目根目录。

剩下的唯一参考资料存在babel-plugin-transform-object-rest-spreadnode_modules所以我猜这些会以某种方式触发它?

包.json

"devDependencies": {
    "@babel/core": "^7.0.0",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0", …
Run Code Online (Sandbox Code Playgroud)

node.js npm babeljs

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

babeljs ×1

node.js ×1

npm ×1