gatsby: [v2] Error: Cannot find module 'core-js/modules/es6.array.filter'
Description
gatsby develop returns the above error
Steps to reproduce
I upgraded a site from v2 to v2 by copying my dependencies, modules & pages over and following the guide here: https://next.gatsbyjs.org/docs/migrating-from-v1-to-v2/
Environment
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.11.3 - /usr/local/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.4.0 - /usr/local/bin/npm
Browsers:
Chrome: 68.0.3440.106
Safari: 11.1.2
npmPackages:
gatsby: 2.0.0-rc.9 => 2.0.0-rc.9
gatsby-plugin-canonical-urls: ^2.0.0-rc.1 => 2.0.0-rc.1
gatsby-plugin-google-tagmanager: ^2.0.0-rc.1 => 2.0.0-rc.1
gatsby-plugin-manifest: next => 2.0.2-rc.1
gatsby-plugin-offline: next => 2.0.0-rc.2
gatsby-plugin-react-helmet: ^3.0.0-rc.1 => 3.0.0-rc.1
gatsby-plugin-remove-trailing-slashes: ^2.0.0-rc.1 => 2.0.0-rc.1
gatsby-plugin-robots-txt: ^1.3.0 => 1.3.0
gatsby-plugin-sitemap: ^2.0.0-rc.1 => 2.0.0-rc.1
gatsby-plugin-styled-components: ^3.0.0-rc.1 => 3.0.0-rc.1
gatsby-source-apiserver: ^1.3.1 => 1.3.1
gatsby-source-filesystem: ^2.0.1-rc.1 => 2.0.1-rc.1
gatsby-source-wordpress: ^3.0.0-rc.1 => 3.0.0-rc.1
gatsby-transformer-javascript-frontmatter: ^2.0.0-rc.2 => 2.0.0-rc.2
gatsby-transformer-json: ^2.1.1-rc.1 => 2.1.1-rc.1
npmGlobalPackages:
gatsby-cli: 1.1.58
I’ve tried installing babel-preset-env and deleting node_modules & reinstalling.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 26 (14 by maintainers)
Commits related to this issue
- Apply fix from https://github.com/gatsbyjs/gatsby/issues/7862 — committed to caycehouse/caycehouse.com by deleted user 5 years ago
- Fix Netlify deploy issue as suggested in https://github.com/gatsbyjs/gatsby/issues/7862 — committed to bluepeter/gatsby-material-ui-business-starter by bluepeter 5 years ago
- Add Google Analytics and avoid issue Avoided [build issue](https://github.com/gatsbyjs/gatsby/issues/7862) — committed to jcunanan05/novascotiaclb-client by jcunanan05 5 years ago
- Trying to workaround Travis CI issue. Potential fix based on https://github.com/gatsbyjs/gatsby/issues/7862. — committed to phyloref/open-tree-resolver by gaurav 5 years ago
- Attempt to fix Travis CI testing issue. Based on https://github.com/gatsbyjs/gatsby/issues/7862#issuecomment-423872754 — committed to phyloref/open-tree-resolver by gaurav 5 years ago
- chore: core-js 디펜던시 추가 `Cannot find module 'core-js/modules/es.function.bind` 에러 해결하려고 추가했습니다. 참고 사이트 https://github.com/gatsbyjs/gatsby/issues/7862 — committed to connect-foundation/2019-04 by lallaheeee 5 years ago
- Fix Netlify deploy issue as suggested in https://github.com/gatsbyjs/gatsby/issues/7862 — committed to dan-84/gatsby-materialui by deleted user 5 years ago
- Fix Netlify deploy issue as suggested in https://github.com/gatsbyjs/gatsby/issues/7862 — committed to dan-84/gatsby-plugin by deleted user 5 years ago
- Bringing code up to now (#54) * Bumped Readme * Stripped bootstrap and scss * Fixed padding on index * Moved Social Icons * Fixed drawer footer * Made sumojoe link safe * Fixed lighthouse best ... — committed to caycehouse/caycehouse.com by deleted user 4 years ago
Thanks Pieh yeah tried that, no go I’m afraid.
I did actually just fix this by running
npm install --save core-jsCan you try deleting lock files (yarn.lock / package-lock.json) and node_modules and reinstalling again?
I had the same issue.
Downgrading my
core-jsversion to2.6.5(dev-dependency) fixed it.Adding
"@babel/polyfill": "^7.0.0",and following those instructions didn’t work for me. Adding core-js did worknpm install --save core-js.<strike>
npm install --save core-js</strike> no longer works.Use
npm install --save --dev core-js@2.6.5instead.However, try running
npm install --dev core-js@2.6.5in the project’s directory so that you do not save it globally.@secretfader You can add
@babel/polyfillto yourdevDependencies, it’ll automatically load necessarycore-jspolyfills. Make sure to delete yournode_modulesfolder and possibly yourpackage-lock.jsonfile and runnpm installto start with a clean resolved dependency tree.@ben-rogerson I should have updated my comment, because the error occurred again after I removed my
package-lock.json. It looks like the dependencies haven’t been resolved correctly, but ironically it worked after doing so. Sometimesnpmis a mystery of rainbow unicorns 🙄 Also in mdx-js/mdx#271 the maintainer posted it didn’t worked withnpm, but when usingyarneverything run fine.I’ll play around with the results when adding
core-jsor@babel/polyfillas dependency, but I’m curious why it works afterwards sincecore-jsis already resolved throughgatsbyand without explicitly importing the polyfill in the code I don’t see any difference between thedevDependenciessolution.I can reproduce the issue. If you are looking for a reproduction repository, https://github.com/mui-org/material-ui/blob/master/examples/gatsby/README.md is a good one.
Installing such packages globally is a really bad idea and there’s no reason to do so. If you’e having problems when installed locally (with pinned version), it might be because you’ve already installed other packages globally that causing conflicts now. I guess the main problem of this ticket is
npm. It seems like it doesn’t resolve the dependency tree correct. I’ve switched toyarnlast year (mainly because of workspaces) and never had problems again. I guess npm users need to use the workaround by pinning the version and hope that npm 8 (that’ll be powered by their new tink lib, announced in their npm Roadmap Summer 2019 blog post) fixes such problems (or switch toyarnfor Gatsby based projects).Got it working thanks to this!
Pieh I had the same issue and I pinpointed it to babel removing the core-js dependency in their 7.0.0 beta versions, before they put it up again in their final version.