Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bimohxh opened this issue Mar 20, 2019 · 38 comments

Comments

@bimohxh
Copy link

bimohxh commented Mar 20, 2019

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�[39m�[22m

�[1m�[31mERROR 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�[39m�[22m

�[1m�[31mERROR 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�[39m�[22m

�[1m�[31mERROR 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�[39m�[22m
....

Additional comments?

this maybe caused by babel use core-js@3

babel/babel#7646

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

This bug report is available on Nuxt community (#c8870)
@ghost ghost added the cmty:bug-report label Mar 20, 2019
@bimohxh bimohxh closed this as completed Mar 20, 2019
@heshamelmasry77
Copy link

heshamelmasry77 commented Mar 25, 2019

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

@heshamelmasry77
Copy link

@bimohxh did you find any solution for it ?

@heshamelmasry77
Copy link

any solution for this

@aldarund
Copy link

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

@solonik1
Copy link

solonik1 commented Apr 9, 2019

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

@aa-ziyi
Copy link

aa-ziyi commented Apr 15, 2019

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

@bimohxh
Copy link
Author

bimohxh commented Apr 17, 2019

不要用 cnpm,换成 npm 即可

@yoelnacho
Copy link

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

  1. delete yarn.lock and node_modules
  2. yarn

It works!

@riux
Copy link

riux commented Nov 28, 2019

I just updated the dependencies and I get this error

@nullablebool
Copy link

nullablebool commented Dec 2, 2019

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

@filrak
Copy link

filrak commented Dec 2, 2019

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

@thebspin
Copy link

thebspin commented Dec 2, 2019

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

@janpansa
Copy link

janpansa commented Dec 5, 2019

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.

@wanxe
Copy link

wanxe commented Dec 11, 2019

Same here! Why is this closed? 🤔

@lupas
Copy link

lupas commented Dec 17, 2019

I keep getting this error randomly in various long-running projects, usually after upgrading nuxt. Just got it again after upgrading to v2.11.0.

Using npm or yarn, deleting node_modules and the lock file, all did not work except manually installing core-js v2 like mentioned above.

Is there an official solution for this problem? I get it for months now randomly.

@wanxe
Copy link

wanxe commented Dec 18, 2019

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

@agcty
Copy link

agcty commented Dec 19, 2019

@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 }
        }
      ]
    ]
  };
};

@regenrek
Copy link

regenrek commented Jan 6, 2020

Same here on 2.11 with yarn build. It works with adding core-js but is there any info why it's necessary to add core-js@x ?

pdt590 added a commit to pdt590/prj-xomcho that referenced this issue Jan 20, 2020
pdt590 added a commit to pdt590/prj-octomaker-blog that referenced this issue Jan 27, 2020
@connorhvnsen
Copy link

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.

@webdawe
Copy link

webdawe commented Feb 13, 2020

Hey Guys,
After adding "core-js": "^2.6.5" , I am getting error
[Vue warn] The .native modifier for v-on is only valid on components but it was used on .
Please advise.
Anil

@lucasoneves
Copy link

I've deleted the yarn-lock.json file and i ran "yarn" again. It worked.

IngvarListard added a commit to IngvarListard/nuxt-django-graphql-example that referenced this issue Mar 15, 2020
@iansamz
Copy link

iansamz commented Apr 1, 2020

I noticed the error occured when i upgraded some dependecies like bootstrap-vue from 2.0.0 to 2.9.0 and nuxt from 2.0.0 to 2.12.1
yarn add core-js@2 did the trick

@skflowne
Copy link

skflowne commented Apr 3, 2020

Getting the same error after adding firebase

Removing node_modules then yarn did not work

yarn add core-js@2 worked though

mskg added a commit to JOWOMO/project-c that referenced this issue Apr 6, 2020
@liberticoding
Copy link

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

@jjangga0214
Copy link

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

@kendalled
Copy link

Can verify @jjangga0214 solution works. Thank you.

@isuke01
Copy link

isuke01 commented May 11, 2020

After install core-js@3 @babel/runtime-corejs3 my PM2 Just break :/

@lupas
Copy link

lupas commented May 11, 2020

@isuke01
https://nuxtjs.org/guide/release-notes#core-js
Install Core JS v2, not 3

@1998code
Copy link

1998code commented Jun 2, 2020

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 :)

@MarcelloTheArcane
Copy link

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.

@richardeschloss
Copy link
Contributor

yeah, I just encountered this issue too :/

@lil-armstrong
Copy link

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

@richardeschloss
Copy link
Contributor

Hi @lil-armstrong thanks for the links! I appreciate it!

@1isten
Copy link

1isten commented Jun 7, 2020

For me I encountered this issue after I upgrade some dependencies using yarn add xxx@latest. I solved this by running npm install after the upgrading (without deleting yarn.lock or package-lock.json). I think this issue may be related to yarn..

Edit: @jjangga0214 is right. Just checkout which version of core-js has been installed in the node_modules and specify the actual core-js version in build.babel in nuxt.config.js. Since Nuxt 2.6 it supports both v2 and v3 of core-js. But by default it's v2 so if any dependency causes v3 installed you have to tell Nuxt through that config option.

@AndrewBogdanovTSS
Copy link

if you are using Yarn you can add resolutions to your package.json like so

"resolutions": {
    "core-js": "2.6.11"
  }

@sabih1996
Copy link

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

how did you fixit?

@TaoHuaXia
Copy link

remove node_modules and lock file then install dosen't work, but npm install core-js@2 works

@ghtali
Copy link

ghtali commented Apr 29, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests