Requires Babel "^7.0.0-0", but was loaded with "6.26.3"

I’m facing the below build issue. Some of dependencies has babel 6 and some has babel 7. But, when a dependency requires babel 7, it was loaded with 6.

  • stack: Error: Requires Babel “^7.0.0-0”, but was loaded with “6.26.3”. If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn’t mention “@babel/core” or “babel-core” to see what is calling Babel.

This happens sometimes due to bad behavior in npm and yarn. When they do optimized package hoisting they don’t reliably satisfy the peerDependencies that each package asked for. It is very annoying.

Sometimes the problem fixes itself if you delete node_modules and try again, sometimes you need to remove your package lock file and let it rebuild. Or you can manually modify the package lock file.

Thanks for your reply!

Unfortunately, it happens in jenkins build. I’m clueless on what to do there to fix it.