Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
loljoho opened this issue Jul 7, 2015 · 71 comments
Closed

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

loljoho opened this issue Jul 7, 2015 · 71 comments

Comments

@loljoho
Copy link

loljoho commented Jul 7, 2015

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.

@silvenon
Copy link
Member

silvenon commented Jul 8, 2015

Thanks for a well-composed issue 👍 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?

@paulballesty
Copy link

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

@timdiacon
Copy link

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?

@silvenon
Copy link
Member

silvenon commented Jul 9, 2015

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

Now it's released in v1.0.3.

@rish
Copy link

rish commented Jul 15, 2015

@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",
....

@silvenon
Copy link
Member

The fix is released, though 😉

@rish
Copy link

rish commented Jul 15, 2015

@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
Copy link

rish commented Jul 15, 2015

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. 😃

@silvenon
Copy link
Member

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

@rish
Copy link

rish commented Jul 15, 2015

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! 🍺

@silvenon
Copy link
Member

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).

@dowsanjack
Copy link

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.

@silvenon
Copy link
Member

npm install -g gulp doesn't help?

@dowsanjack
Copy link

👎 nopes.

@silvenon
Copy link
Member

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.

@dowsanjack
Copy link

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

@silvenon
Copy link
Member

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

almex added a commit to almex/modernWebDevGenerator that referenced this issue Oct 15, 2015
Following [this](yeoman/generator-webapp#356) 'babel' seems to have been renamed into 'babel-core'
@shadowmint
Copy link

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

@silvenon
Copy link
Member

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?

@Revod
Copy link

Revod commented Oct 31, 2015

I have the same problem, tried that #356 (comment) and nope 👎

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

@rish
Copy link

rish commented Oct 31, 2015

@Revod I have posted a new issue on the gulp repo here:

gulpjs/gulp#1364 it might be related?

@blackfyre
Copy link

Installing the babel-corelocally with npm install --save-dev babel-core solved my problem, but the SyntaxError: Unexpected reserved word problem still remains when trying to run gulp serve.

@Revod
Copy link

Revod commented Nov 19, 2015

I solved my problem uninstalling Node and NPM and reinstall using this guide of Team TreeHouse

@blackfyre
Copy link

This article held the solution for my problems.

@SpadeRubick
Copy link

SpadeRubick commented May 10, 2016

Tasks completed with the error

run 'gulp dist'
[11:27:20] Failed to load external module babel-register
[11:27:20] Requiring external module babel-core/register
[11:27:25] Using gulpfile F:\Gary\gulpfile.babel.js
[11:27:25] Starting 'js'...
[11:27:25] Finished 'js' after 8.57 ms
[11:27:25] Starting 'css'...
[11:27:25] Finished 'css' after 3.91 ms
[11:27:25] Starting 'html'...
[11:27:25] Finished 'html' after 1.84 ms
[11:27:25] Starting 'dist'...
[11:27:25] Finished 'dist' after 6.53 μs

package.json:

"devDependencies": {
    "babel": "^6.5.2",
    "babel-core": "^6.8.0",
    "babel-preset-es2015": "^6.6.0",
    "gulp": "^3.9.1",
    ……
  }

@richyrb00
Copy link

I found that i was using node v6

i moved it back down to v4.4.4

this then fixed the issue but still getting an error with failed to load external module babel-register so i installed that which then took me back to square one which a lot of you posted. i think uninstalled that again and although it hows failed to load external module babel-register.. it works :)

I think is you too node down to 4.2.6 (as i have another system on this version) it should work as required with no issues.

@silvenon
Copy link
Member

silvenon commented May 16, 2016

A new version was released where we don't parse gulpfile with Babel anymore (i.e. we renamed gulpfile.babel.js to gulpfile.js), because Node v4+ support a lot of ES2015 features. So this issue should be gone. Hopefully people will stop torturing this poor thread 😓

@bleedkaga
Copy link

hello:
I am is run 'gulp wiredep' , There is an error 'must start with number, buffer, array or string', excuse me how should solve?
Thanks!
------------------ Original ------------------
From: "Matija Marohnić"notifications@github.com;
Date: Tue, May 17, 2016 05:43 AM
To: "yeoman/generator-webapp"generator-webapp@noreply.github.com;
Cc: "bleedkaga"wenfp@palmtrends.com; "Manual"manual@noreply.github.com;
Subject: Re: [yeoman/generator-webapp] gulp serve: Failed to load externalmodule babel-core/register (#356)

A new version was released where we don't parse gulpfile with Babel anymore (i.e. we renamed gulpfile.babel.js to gulpfile.js), because Node v4+ support a lot of ES2015 features. So this issue should be gone.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

@silvenon
Copy link
Member

@bleedkaga please raise a new issue, this is not related to babel-register.

@bleedkaga
Copy link

Can you tell me how to solve this problem? @silvenon

@silvenon
Copy link
Member

@bleedkaga Maybe. If you open a new issue 😁

@amaalzohny
Copy link

in index.js
`
if (env === 'development' || env === 'test') {
// Register the Babel require hook
//require('babel-register');
require('babel-register')({
presets: [ 'es2015' ]
});
}

`

@thecreation
Copy link

I am using ubuntu 14.04. And i am using nvm managing the nodejs.

Runing gulp -v getting the error below

[20:54:47] Failed to load external module babel/register
[20:54:47] CLI version 3.9.0
[20:54:47] Local version 3.9.1

And the issue was solved by the steps below:

sudo rm -r /usr/lib/node_modules/
sudo rm /usr/bin/gulp
npm cache clear
npm uninstall gulp-cli -g
npm uninstall gulp -g
npm install gulp-cli -g

Hope it will be helped for whom that using nvm.

@karthikeyana
Copy link

i found solution
npm install babel-cli babel-preset-es2015

@quangthien27
Copy link

Adding .babelrc file may help

{
  "presets": [
    "es2015"
  ]
}

@NeverMore93
Copy link

@baermowei @mqliutie @kevin-kang @xiao-ai 你们TM能用英语嘛?丢人丢到外国去了,shame on you!!!

@NeverMore93
Copy link

@mqliutie 觉得好用点赞就行,别TM废话,你以为csdn还是贴吧啊

@mqliutie
Copy link

mqliutie commented Aug 4, 2017

@NeverMore93 满足脏话在这和我说丢人? 我回的是国人,讲中文有问题?和国人还要拽英文?你英语多厉害?嫌丢人你别出来不就好了?

@YDD9
Copy link

YDD9 commented Oct 23, 2017

@Marshevskyy
Thanks, this npm install -g gulp@3.9.0 works !
then I just npm i gulp && gulp build for my app.

@msangel
Copy link

msangel commented Dec 13, 2017

Yes, gulp 3.9.0 make this as an warning, not an error, but I still feel like I am doing something wrong.

hellolibo added a commit to hellolibo/webpack-demo that referenced this issue Dec 17, 2017
@lipis
Copy link

lipis commented Jan 23, 2018

Can someone just fix this sh*t? Obviously is not working..

@silvenon
Copy link
Member

@lipis what isn't working?

@lipis
Copy link

lipis commented Jan 23, 2018

@silvenon I think I found the appropriate project to post the issue: gulpjs/gulp-cli#150 sorry for "aggresive" post.. but this issue is circling the web for the last two years..

@silvenon
Copy link
Member

Ah, I didn't realize that this threw an actual error, that's bad… I hope someone will fix it.

@markgreve
Copy link

For me this was a gulp v3.9.1 issue
deleted node_modules folder
ran
npm uninstsall gulp
npm install gulp@3.9.0

npm unistall --save-dev gulp
deleted node_modules folder
npm install --save-dev gulp@3.9.0

gulp -v
Requiring external module babel-core/register
CLI version 3.9.0
Local version 3.9.0

Everything now works.

@silvenon
Copy link
Member

silvenon commented Jan 24, 2018

Yeah, that is a Gulp issue and should be dealt with in their issue tracker.

If someone finds an issue with this generator, please open a new issue.

P.S. The reason for locking this issue says "too heated" because that was the most appropriate one on the list. I don't think anyone here was out of line, just that the discussion got a bit chaotic and that the issue has been identified.

@yeoman yeoman locked as too heated and limited conversation to collaborators Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests