gulp-babel: Cannot find module 'babel-core'

I’ve just updated from 6.1.2 to 7.0.0 and I now get this error message:

[17:08:05] 'requirejs' errored after 68 ms
[17:08:05] Error: Cannot find module 'babel-core'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/.../Client/node_modules/gulp-babel/index.js:7:15)
    at Module._compile (module.js:570:32)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 30
  • Comments: 29 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Install babel-core as your dev dependency and it will work.

npm install --save-dev babel-core babel-preset-env

Update

As of babel 7, install the dependency via the following command instead

npm install --save-dev @babel/core @babel/preset-env

It wasn’t working for me too, until I read the README. It clearly says: npm install --save-dev gulp-babel @babel/core @babel/preset-env 👍

Babel 6:

npm install --save-dev The following:

@babel/cli
@babel/core
@babel/preset-env

Babel 7:

npm install --save-dev The following:

babel-cli
babel-core
babel-preset-env

Thank you, this worked. The release notes say:

made babel-core a peerDependency instead of dependency and supports v6/v7/(alpha/beta/rc for v7)

could you please make it a bit more explicit that something is required from the users? A note in the README would be nice as well.

Babel 6:

npm install --save-dev The following:

@babel/cli
@babel/core
@babel/preset-env

Babel 7:

npm install --save-dev The following:

babel-cli
babel-core
babel-preset-env

For anyone finding themselves down this rabbit hole, this comment is the exact opposite of reality. Babel 7 moved to the @babel namespace.

The messaging from npm probably isn’t super obvious, but yeah this was a change in 7.0. babel-core is now expected to be a peer dependency. When I install it on my machine for instance:

$ npm i gulp-babel
/private/tmp
├── UNMET PEER DEPENDENCY babel-core@6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc
└─┬ gulp-babel@7.0.0 
 
<<  a bunch of stuff I removed  >>

npm WARN gulp-babel@7.0.0 requires a peer of babel-core@6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc but none was installed.

which tries to convey this, but unless you’re looking for it, it’s pretty easy to miss.

For me the only working solution for Babel 7 was from Babel setup guide. Note the gulp-babel@next

npm install --save-dev gulp-babel@next @babel/core @babel/preset-env

I keep getting an error on windows machine.

cannot find module 'babel-core'

The Setup page in the docs on babeljs.io doesn’t mention this either:

npm install --save-dev gulp-babel

If you are using @babel-core (v7.0+) you need to upgrade to the latest version of babel-loader (v8.0) simply run this command.

npm install -D babel-loader@8.0.0

Thought I’d add my own solution: delete package-lock.json and try again.

I have this issue crop up from time to time. Deleting package-lock.json solves it every time.

I could fix it by this link

https://github.com/babel/babel-loader