Nuxt.js Cannot find module '@babel/preset-env/lib/utils' Nuxt.js Cannot find module '@babel/preset-env/lib/utils' vue.js vue.js

Nuxt.js Cannot find module '@babel/preset-env/lib/utils'


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"    ]  },


I did the following:

npm uninstall @babel/preset-env

npm install @babel/preset-env@7.12.13