8

I installed babel-core, babel-loader, and a few other packages via npm

npm install babel-loader babel-core ...

This resulted in the following definitions in my package.json

"dependencies": {
  "babel-core": "^6.26.3",
  "babel-loader": "^8.0.0",
  ...
},

At the time of this question, the latest version of babel-core is indeed 6.26.3 and the latest version of babel-loader is 8.0.0 as per npmjs.com repository.

However when I run npm install again to verify everything, I get this message:

npm WARN babel-loader@8.0.0 requires a peer of @babel/core@^7.0.0 but none is installed. You must install peer dependencies yourself.

Why would babel-loader depend on a version of babel-core that doesn't exist yet? And what's the recommended way to resolve this warning?

Thanks!

EDIT Looks like the babel-loader library was published only 4 days ago. Could this be a relatively recent problem caused by this being published?

enter image description here

user2490003
  • 10,706
  • 17
  • 79
  • 155
  • To clarify, instead of `babel-core` you need to install `@babel/core`. There's not something wrong with the package, you've just installed the wrong core. Is there something we can do to improve documentation would this? The installation docs even include examples of both: https://www.npmjs.com/package/babel-loader – loganfsmyth Aug 31 '18 at 17:12

3 Answers3

9

babel-loader@8.x is the Webpack integration used for Babel 7.x. Babel 7.x has moved all packages from a babel- prefix to the @babel npm scope.

The error is correct, you have incorrectly installed babel-core instead of @babel/core.

If you wish to install Babel 6.x, you can do

npm install --save-dev babel-loader@7 babel-core

but if you're starting a new project, Babel 7 makes much more sense, so you would ideally do

npm install --save-dev babel-loader @babel/core
torrao
  • 291
  • 8
  • 17
loganfsmyth
  • 156,129
  • 30
  • 331
  • 251
2

I had the same error just 5 minutes ago, I fixed that with reinstalling babel-loader.

npm r babel-loader
npm i babel-loader@7
0

So it was a versioning issue as I suspected.

I went to the babel-loader version history page and found a version of babel-loader that was published around the same time as the latest babel-core version, so it was likely they would work well with each other.

In this case it was 7.1.4 from 6 months ago.

Everything worked great from there. It's incredibly disappointing that one of the key benefits of package managers is that they solve dependency issues but a project such as this has such a profoundly basic failure.

"dependencies": {
  "babel-core": "^6.26.3",
  "babel-loader": "^7.1.4",
  ...
},

enter image description here

user2490003
  • 10,706
  • 17
  • 79
  • 155