generator-webapp icon indicating copy to clipboard operation
generator-webapp copied to clipboard

gulp serve: Failed to load external module babel-core/register

Open loljoho opened this issue 11 years ago • 71 comments

Followed the directions in README.md and I receive this error when I run gulp serve:

$ gulp serve
[11:26:22] Failed to load external module babel-core/register
[11:26:22] Requiring external module babel/register

It does, however, serve the boilerplate welcome page successfully.

System/Software Information

$ sw_vers && node -e 'console.log(process.platform, process.versions)'
ProductName:    Mac OS X
ProductVersion: 10.10.3
BuildVersion:   14D136
darwin { http_parser: '2.3',
  node: '0.12.5',
  v8: '3.28.71.19',
  uv: '1.6.1',
  zlib: '1.2.8',
  modules: '14',
  openssl: '1.0.1o' }
$ npm -v
2.12.1
$ yo --version
1.4.7
$ bower -v
1.4.1
$ gulp -v
[11:28:30] CLI version 3.9.0

I attempted a clean install, and retraced every step for a second time in a new directory and I am still encountering the same error.

I must note that I am new to Babel, so I have no idea whether or not this has any consequence; I apologise in advance if this is benign.

loljoho avatar Jul 07 '15 15:07 loljoho

Thanks for a well-composed issue :+1: This error happened because for some reason you don't have babel installed in your project, i.e. in the node_modules directory. We put it in devDependencies in package.json, so the npm install command which ran after scaffolding should've installed it. Could you poke around to see why this is not the case?

silvenon avatar Jul 08 '15 00:07 silvenon

Had the same issue. Managed to fix it installing babel-core with npm install --save-dev babel-core.

paulballesty avatar Jul 08 '15 13:07 paulballesty

I'm getting this error too with latest version of generator - can be fixed as per comment from paulballesty but surely should just be in the package.json so gets installed to begin with no?

timdiacon avatar Jul 09 '15 09:07 timdiacon

It was fixed in 31348ff1acc393af507a7b8a192d767cf9737021, as the reference above your comment says, it just wasn't released yet :wink:

Now it's released in v1.0.3.

silvenon avatar Jul 09 '15 14:07 silvenon

@timdiacon I managed to monkey patch this by adding babel pack into the devDependencies for the package.json that this generator creates, like so:

"babel-core": "^5.5.6",
"babel": "^5.5.6",
....

rish avatar Jul 15 '15 09:07 rish

The fix is released, though :wink:

silvenon avatar Jul 15 '15 09:07 silvenon

@silvenon Yes I was trying to simulate this via the fix but this doesn't work on a fresh version of a generated app.

rish avatar Jul 15 '15 10:07 rish

Ok so I have resolved this by upgrading my node version to iojs-v2.3.4 which would start with a fresh copy of the ~/.npm directory. This may have been an npm caching issue.

But I was able to successfully run the generator with a global install of just yo, gulp, bower.

Thank you for the assistance though @silvenon. :smiley:

rish avatar Jul 15 '15 10:07 rish

Glad you got it working :+1: Yeah, probably a caching issue. What was the error you were encountering when trying with the latest release?

silvenon avatar Jul 15 '15 10:07 silvenon

So trying this out on another machine where I'm using iojs-2.2.1 and ensuring it's not an npm caching issue:-

[22:32:43] Failed to load external module babel/register
/Users/{user}/{project_dir}/gulpfile.babel.js:2
import gulp from 'gulp';
^^^^^^
SyntaxError: Unexpected reserved word
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:409:25)
    at Object.Module._extensions..js (module.js:444:10)
    at Module.load (module.js:351:32)
    at Function.Module._load (module.js:306:12)
    at Module.require (module.js:361:17)
    at require (module.js:380:17)
    at Liftoff.handleArguments (/Users/{user}/.nodenv/versions/iojs-2.2.1/lib/node_modules/gulp/bin/gulp.js:116:3)
    at Liftoff.<anonymous> (/Users/{user}/.nodenv/versions/iojs-2.2.1/lib/node_modules/gulp/node_modules/liftoff/index.js:192:16)
    at module.exports (/Users/{user}/.nodenv/versions/iojs-2.2.1/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3)

Installing iojs-2.3.4 and it works.

May be worth mentioning this as a requisite on the README?

I can create a pull request if you would prefer to identify this.

I don't have any spare time to test this out on previous iojs-2.3.* versions or other official versions but it would be could so set the minimum version required due to breaking changes from multiple dependencies.

Thank you for the patches though, for this very useful generator, none the less! :beer:

rish avatar Jul 15 '15 22:07 rish

The problem is that gulp is still searching for babel/register instead of babel-core/register (babel module was renamed to babel-core). You should reset it by reinstalling it – npm install --global gulp did it for me. (This is probably what you did as part of reinstalling iojs).

silvenon avatar Jul 15 '15 22:07 silvenon

I'm still having this issue, where gulp is searching for babel/register. gulp serve is echoing the following output:

[13:14:40] Failed to load external module babel/register
/Users/ankit/dev/coffee/gulpfile.babel.js:2
import gulp from 'gulp';
^^^^^^
SyntaxError: Unexpected reserved word
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
    at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:192:16)
    at module.exports (/usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3)

Gulp version : 3.9.0

When I do gulp -v:

[13:53:28] Failed to load external module babel/register
[13:53:28] CLI version 3.9.0
[13:53:28] Local version 3.9.0

Can anyone guide where things are going wrong.

dowsanjack avatar Jul 30 '15 08:07 dowsanjack

npm install -g gulp doesn't help?

silvenon avatar Jul 30 '15 08:07 silvenon

:-1: nopes.

dowsanjack avatar Jul 30 '15 08:07 dowsanjack

Couple of ideas:

  • npm cache clean
  • npm uninstall -g gulp, open a new Terminal tab, npm install -g gulp
  • reinstall node, as a last resort

Try them out. The last one should work, but it shouldn't really come to that.

silvenon avatar Jul 30 '15 08:07 silvenon

Did what you advised, but no change in output. :( . Even reinstalled node.

dowsanjack avatar Jul 30 '15 09:07 dowsanjack

Whoa… that should've worked :confused: Are you on OS X? Are you up for pairing with tmate?

silvenon avatar Jul 30 '15 09:07 silvenon

I'm seeing this on ubuntu too.

[10:4:00] Failed to load external module babel/register
[10:44:00] CLI version 3.9.0
[10:44:00] Local version 3.9.0

To fix I had to install babel, not babel-core.

doug@doug-VirtualBox:~/wok$ gulp --version
[10:55:23] Requiring external module babel-core/register
[10:55:23] CLI version 3.9.0
[10:55:23] Local version 3.9.0
doug@doug-VirtualBox:~/wok$ node --version
v0.10.25

Weirdly this does work on OSX without any problem.

No idea, but it's weird.

Notice how once babel is installed it tries for babel-core/register instead of babel/register. What is up with that? O_o

shadowmint avatar Oct 26 '15 02:10 shadowmint

Gulp searches for both. First babel-core/register, then babel/register. I'm not sure anymore whether Babel wants us to install babel or babel-core?

silvenon avatar Oct 26 '15 11:10 silvenon

I have the same problem, tried that https://github.com/yeoman/generator-gulp-webapp/issues/356#issuecomment-126231339 and nope :-1:

I have elementary os (based ubuntu) node --version: v4.2.1

gulp --version [05:27:45] Failed to load external module babel-core/register [05:27:45] Failed to load external module babel/register [05:27:45] CLI version 3.9.0 [05:27:45] Local version 3.9.0

Revod avatar Oct 31 '15 09:10 Revod