Reputation: 422
I'm trying to upgrade from Babel 6 -> 7. I used npx babel-upgrade --write
to assist with updating the package.json
and then ran a npm install
.
When trying to run our webpack dev server, it fails to compile with the following error:
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)
Note /vagrant
is the project root.
The only references left to babel-plugin-transform-object-rest-spread
exist in node_modules
so my guess is these are triggering it somehow?
package.json
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"autoprefixer": "^9.0.1",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.4.2",
"babel-loader": "^8.0.0",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-react-transform": "^3.0.0",
"css-loader": "^1.0.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.4",
"eslint": "^5.2.0",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-standard": "^3.1.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.7.1",
"jest-fetch-mock": "^1.6.5",
"lodash-webpack-plugin": "^0.11.5",
"mini-css-extract-plugin": "^0.6.0",
"path": "^0.12.7",
"postcss": "^7.0.1",
"postcss-cssnext": "^3.0.2",
"postcss-loader": "^2.1.6",
"postcss-modules-values": "^1.3.0",
"raw-loader": "^0.5.1",
"react-test-renderer": "^16.4.1",
"redux-mock-store": "^1.5.3",
"sinon": "^6.1.4",
"standard": "^11.0.0",
"style-loader": "^0.21.0",
"svg-react-loader": "^0.4.5",
"uglifyjs-webpack-plugin": "^1.2.7",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.1",
"webpack-dev-server": "^3.3.1",
"webpack-merge": "^4.1.3",
"webpack-visualizer-plugin": "^0.1.11"
},
.babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread"
]
}
Edit: I've been unable to identify the cause of the issue and have reverted to Babel 6.
Upvotes: 6
Views: 19825
Reputation: 696
Can be resolve by
npm i --save-dev @babel/plugin-proposal-object-rest-spread
Upvotes: -1
Reputation: 1930
If you support legacy project and try to update some dependencies like me. In your babel config:
{
plugins: [
'@babel/plugin-proposal-object-rest-spread'
]
}
This is not a "proposal" anymore. Replace with:
{
plugins: [
'@babel/plugin-transform-object-rest-spread'
]
}
Upvotes: 6
Reputation: 93
updated presets from and used @user14981617's advice.
https://babeljs.io/docs/en/env/ was recommended in terminal.
npm WARN deprecated [email protected]: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!
:)
this is what I have currently:
{
"presets": [
["env", {
"modules": false,
"targets": {
"chrome": "60",
"edge": "60",
"node": "current"
}
}],
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread"]}
Upvotes: 1
Reputation: 83
Had this issue and was able to solve it after some digging --
we still had a transform-object-rest-spread
left in the plugins in our webpack configuration and in our package.json
, without the babel prefix. Replacing it with @babel/plugin-proposal-object-rest-spread
fixed it for us!
Upvotes: 7