nuxt: Module not found: Error: Can't resolve 'core-js/modules/es6.array.iterator' in '/app/.nuxt'

Version

v2.4.5

Reproduction link

https://github.com/nuxt/nuxt.js

Steps to reproduce

just remove your node_modules and npm install and npm run build

What is expected ?

build success

What is actually happening?

build error

Module not found: Error: Can’t resolve ‘core-js/modules/es6.array.iterator’ in ‘/app/.nuxt’ @ ./.nuxt/client.js 15:0-44 @ multi ./.nuxt/client.js

ERROR in ./.nuxt/utils.js Module not found: Error: Can’t resolve ‘core-js/modules/es6.date.to-string’ in ‘/app/.nuxt’ @ ./.nuxt/utils.js 6:0-44 @ ./.nuxt/client.js @ multi ./.nuxt/client.js

ERROR in ./.nuxt/client.js Module not found: Error: Can’t resolve ‘core-js/modules/es6.function.name’ in ‘/app/.nuxt’ @ ./.nuxt/client.js 14:0-43 @ multi ./.nuxt/client.js

ERROR in ./.nuxt/index.js Module not found: Error: Can’t resolve ‘core-js/modules/es6.function.name’ in ‘/app/.nuxt’ @ ./.nuxt/index.js 6:0-43 @ ./.nuxt/client.js @ multi ./.nuxt/client.js …

Additional comments?

this maybe caused by babel use core-js@3

https://github.com/babel/babel/pull/7646

https://github.com/babel/babel/releases/tag/v7.4.1

<div align="right">This bug report is available on Nuxt community (#c8870)</div>

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 11
  • Comments: 38 (2 by maintainers)

Commits related to this issue

Most upvoted comments

i hate @cmty no one answer anything there and not on the search on google :S stop closing issues

Guys, following the docs resolved the issue: https://nuxtjs.org/guide/release-notes#v2.6.0

yarn add -D core-js@3 @babel/runtime-corejs3
# or
npm i -D core-js@3 @babel/runtime-corejs3

Then edit nuxt.config.js.

export default {
  build: {
    babel: {
      presets({ isServer }) {
        return [
          [
            require.resolve('@nuxt/babel-preset-app'),
            // require.resolve('@nuxt/babel-preset-app-edge'), // For nuxt-edge users
            {
              buildTarget: isServer ? 'server' : 'client',
              corejs: { version: 3 }
            }
          ]
        ]
      }
    }
  }
}

Same issue with nuxt 2.6.1. “core-js”: “^2.6.5” fixed the issue

package.json "dependencies": { "core-js": "^2.6.5", "nuxt": "2.6.3", ... },

  1. delete yarn.lock and node_modules
  2. yarn

It works!

We were getting the same issue after doing an npm install. The issue started when we installed file-loader for adding a specific sound file. Thereafter, referted back from using file-loader and uninstalled it. We the started getting the error messages of core-js not resolved.

We added core-js manually, however this installed the latest corejs version (3.x) and did not work.

Had to manually add core-js :

npm install core-js@2.6.10 --save

However, this is very ‘hacky’ solution since this message appears when installing:

core-js@<3.0 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.

Our project is working now, but for how long untill it is no longer support. It also feels ‘hacky’ since core-js was never required to be manually installed.

Getting the same error after adding firebase

Removing node_modules then yarn did not work

yarn add core-js@2 worked though

@wanxe @filrak I solved it by following the steps outlined here: https://www.npmjs.com/package/@nuxt/babel-preset-app#example-2-use-core-js3

In addition, I clean up my nuxt.config.js file by outsourcing the babel config in its own babel.config.js file.

nuxt.config.js

build: {
    babel: {
      configFile: "./babel.config.js"
    }
}

babel.config.js

module.exports = function(api) {
  return {
    presets: [
      [
        "@nuxt/babel-preset-app",
        {
          corejs: { version: 3 }
        }
      ]
    ]
  };
};

@riux try @yoelnacho answer. I had to yarn add core-js@2.6.10 (v3 does not seem to be supported).

I have only done what they propose here and everything works perfectly in 2.11.0 👍

Guys, follow the docs to resolve the issue: https://nuxtjs.org/guide/release-notes#v2.6.0

yarn add -D core-js@3 @babel/runtime-corejs3
# or
npm i -D core-js@3 @babel/runtime-corejs3

Then edit nuxt.config.js.

export default {
  build: {
    babel: {
      presets({ isServer }) {
        return [
          [
            require.resolve('@nuxt/babel-preset-app'),
            // require.resolve('@nuxt/babel-preset-app-edge'), // For nuxt-edge users
            {
              buildTarget: isServer ? 'server' : 'client',
              corejs: { version: 3 }
            }
          ]
        ]
      }
    }
  }
}

Solution works

Same here! Why is this closed? 🤔

@heshamelmasry77 clean lock file and node modules and resintall, if it dont help -> add core-js@2 at your project

I just updated the dependencies and I get this error

Simple and painless solution. Just add or update core-js.

for npm:

npm i -S core-js@2.5.7

for yarn:

yarn add core-js@2.5.7

Getting the same error after adding firebase

Removing node_modules then yarn did not work

yarn add core-js@2 worked though

Thank you! Works 😃

Having the same issue on my deployment server…, even adding core-js manually won’t work for me.

I still got this error. Adding core-js manually is not the best option since it breaks modern build @pi0 any advices?

It’s still not ideal:

warning core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.

Can verify @jjangga0214 solution works. Thank you.

why there no core team answering this problems, like where are they, they supposed to helps us, not to let us fighting this error, I am disappointed

I’ve deleted the yarn-lock.json file and i ran “yarn” again. It worked.

I was having issues using npm. Fix was to remove package.lock, remove node_modules, add “core-js”: “^2.6.5” to deps and run yarn install.

yarn add core-js 如果还不行 删除 node_modules,然后使用 yarn 安装,不要使用 cnpm 安装;