Nuxt.js Cannot find module '@babel/preset-env/lib/utils'
@babel/preset-env updated, use old version 7.12.17 https://www.npmjs.com/package/@babel/preset-env/v/7.12.17
This issue drove me crazy for a few hours too.
The solution is to add to nuxt.config.js
into build
section:
/*
** Build configuration
*/
build: {
babel: {
presets(env, [ preset, options ]) {
return [
[ "@babel/preset-env", options ]
]
}
},
Make sure you have that thing installed:
npm install --save-dev @babel/preset-env
or in your case with yarn
Updated:
Then I encountered another error
regeneratorRuntime is not defined
Here is working part from my config.nuxt.js
build: {
babel: {
presets({isServer}) {
const targets = isServer ? { node: 'current' } : { ie: 11 }
return [
[ require.resolve("@babel/preset-env"), { targets } ]
]
},
plugins: [
"@babel/syntax-dynamic-import",
"@babel/transform-runtime",
"@babel/transform-async-to-generator"
]
},