storyblok / gatsby-storyblok-boilerplate

Gatsby starter template with Storyblok's headless cms and true preview
https://www.storyblok.com/tp/add-a-headless-cms-to-gatsby-5-minutes
BSD Zero Clause License
37 stars 28 forks source link

Cannot find module 'core-js/modules/es6.regexp.split' #12

Closed BrieucCaillot closed 4 years ago

BrieucCaillot commented 4 years ago

Hi! I've just cloned the repo and after i run yarn install & gatsby develop, i get the following error :

Error in "/Users/Brieuc/Sites/GITHUB/gatsby-storyblok-boilerplate/node_modules/gatsby-source-storyblok/gatsby-node.js": Cannot find module 'core-js/modules/es6.regexp.split'

  Error: Cannot find module 'core-js/modules/es6.regexp.split'

  - loader.js:636 Function.Module._resolveFilename
    internal/modules/cjs/loader.js:636:15

  - loader.js:562 Function.Module._load
    internal/modules/cjs/loader.js:562:25

  - loader.js:692 Module.require
    internal/modules/cjs/loader.js:692:17

  - v8-compile-cache.js:159 require
    [gatsby-storyblok-boilerplate]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - index.js:15 Object.<anonymous>
    [gatsby-storyblok-boilerplate]/[storyblok-js-client]/dist/index.js:15:1

  - v8-compile-cache.js:178 Module._compile
    [gatsby-storyblok-boilerplate]/[v8-compile-cache]/v8-compile-cache.js:178:30

  - loader.js:789 Object.Module._extensions..js
    internal/modules/cjs/loader.js:789:10

  - loader.js:653 Module.load
    internal/modules/cjs/loader.js:653:32

  - loader.js:593 tryModuleLoad
    internal/modules/cjs/loader.js:593:12

  - loader.js:585 Function.Module._load
    internal/modules/cjs/loader.js:585:3

  - loader.js:692 Module.require
    internal/modules/cjs/loader.js:692:17

  - v8-compile-cache.js:159 require
    [gatsby-storyblok-boilerplate]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - gatsby-node.js:1 Object.<anonymous>
    [gatsby-storyblok-boilerplate]/[gatsby-source-storyblok]/gatsby-node.js:1:87

  - v8-compile-cache.js:178 Module._compile
    [gatsby-storyblok-boilerplate]/[v8-compile-cache]/v8-compile-cache.js:178:30

  - loader.js:789 Object.Module._extensions..js
    internal/modules/cjs/loader.js:789:10

  - loader.js:653 Module.load
    internal/modules/cjs/loader.js:653:32

not finished load plugins - 0.357s
heresandyboy commented 4 years ago

Hi, I can confirm this issue. Temporary workaround is to directly install dependency core-js and pin to the older version 2.6.5

yarn install core-js@2.6.5

However this is likely to cause issues with some other Gatsby plugins.

I have yet to take the time to dig any deeper, however it's clear the issue comes from breaking changes in core-js v3.x.x.

CHANGELOG.md#300---20190319

Move all features from ES5, ES2015, ES2016, ES2017, ES2018 and ES2019 to one namespace for stable ES 
- it's available as core-js/es, all those features in modules folder has es. prefix.
Change prefix for ES proposals from es7. to esnext., they no longer available in core-js/es7, use core-js/stage/* instead of that.

Meaning any references to core-js modules that use the es number, like core-js/modules/es6.regexp.split actually need to be refactored to something like 'core-js/modules/es.regexp.split

core-js@3.6.5 is coming in as a dependency for all the gatsby plugins, however the following dependencies pull in core-js@2.6.11

There is also an issue regarding the same issue on the gatsby-source-storyblok git repo: #27

Hopefully a fix would be to update all dependencies to latest but I have not tried this, it depends if those have updated to core-js 3.x.x also.

Update: It looks like storyblok-js-client is now using @babel/runtime-corejs3, couldn't see when it was updated, but current version is storyblok-js-client@2.5.1, however gatsby-source-storyblok is still using storyblok-js-client@1.0.22

Looks like we need a fair bit of upstream maintenance to get this sorted. I'll see if I can commit any time but help would be awesome.

heresandyboy commented 4 years ago

My pull request to fix this was merged and an update to gatsby-source-storyblok was pushed to npm today as v1.0.0. I'll submit a PR to pull the updated package into this repo for others to benefit.

Those of you having this problem can just update your dependencies and make sure to remove the direct reference to core.js 2.x.x to benefit from core.js 3.0 support.

emanuelgsouza commented 4 years ago

Hi, thanks for submitting this issue, @BrieucKyo and thanks @heresandyboy for your work!

I updated the dependencies of repository, now, it all works well. I'll close this issue.