question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dependency conflict with outdated "core-js" for "@mdx-js/tag" package

See original GitHub issue

First things first: Thanks for your great work, I love MDX and migrated all my projects to it. Finally writing Markdown and adding dynamic/non-specification via React elements to it is what I’ve always wanted to create content 😄

I working on one of my favorite projects again after a long time and started with updating from the Gatsby v2 Beta to the stable v2 release. This also included all the other outdated dependencies one-by-one for easier debugging when an error occurs and unfortunately it then failed with the following:

Error: Cannot find module 'core-js/modules/es6.array.filter'

I’ve debugged and burrowed down the dependency tree and came to the decision that the error must be caused by the @mdx-js/tag package.

gh-271-deptree-core-js

As you can see on the screenshot the @mdx-js/tag package depends on create-react-context@^0.2.2 which resolves to create-react-context@0.2.3. The package in turn depends on an outdated 0.x.x version of fbjs (^0.8.0, latest stable version is 1.0.0) which resolves to fbjs@0.8.17.

Now the fbjs package finally depends on the core-js package which module has not been found causing the error to be thrown. This outdated version of fbjs (0.8.17) depends on the outdated package core-js@^1.0.0, but the latest version is a new major release of 2.5.7. This latest version is also used by other dependencies as you can see on the screenshot including the latest Gatsby version (via the latest Babel v7 @babel/polyfill).

The problem can now be nailed down to the fact that core-js@1.2.7 does not provide the Array.filter polyfill. The first version providing it is core-js@2.1.0.

Here is a example Codesandbox which reproduces the problem. Note that it can not be run within the browser because of Gatsby. Just copy/download/fork/clone it and run it locally via npm run dev.

Edit kopk420yjv

I solved the problem with an workaround by just adding @babel/polyfill (or core-js directly) to devDependencies in my project. This resolves the correct required version of core-js to fix the error.

I currently don’t know how to solve the problem here for the @mdx-js/tag package. Adding @babel/polyfill or core-js as (peer) dependency might now be a good idea, but removing create-react-context might be a better solution.

Is it a problem to increase the required React version to 16.3+ to use the native Context API implementation instead of using a polyfill package? This might be the best solution, but this would be a breaking change =/

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
arcticicestudiocommented, Sep 23, 2018

I think the problem can be led back to the Babel 7 changes for the @babel/polyfill package. Thanks for your help 👍 , I’ll track the referenced issue (have searched through Gatsby issue, but haven’t found this one -.-).

1reaction
silvenoncommented, Sep 23, 2018

Thanks! I managed to reproduce the error with npm, but with Yarn everything works fine. 🤔

It seems like this might be an edge case with npm (gatsbyjs/gatsby#7862), which is why I’m not inclined to add any workarounds in this package until we can prove that the error is legitimate, i.e. that npm is resolving these dependencies correctly.

In the meantime, npm install core-js should fix your error. 😉

I’m closing this, but I’m open for further discussion if you know that the error isn’t npm’s fault and wish to investigate this deeper. ⭐️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix the upstream dependency conflict installing NPM packages
Probably one of your packages is outdated. Upgrading packages and fixing upgrade errors might fix the dependency conflict.
Read more >
How to update core-js to core-js@3 dependency - Ask Ubuntu
You can update core-js by running this command: npm install --save core-js@^3.
Read more >
core-js | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
core-js - npm
Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is...
Read more >
Troubleshoot dependency version conflicts - Azure
0' of package 'jackson-core' is not supported (too old), please upgrade. Note. Check that all of the Jackson packages have the same version....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found