foundation-cli icon indicating copy to clipboard operation
foundation-cli copied to clipboard

Babel error with foundation watch command

Open colin-marshall opened this issue 9 years ago • 17 comments

A user in zurb/foundation-sites#8560 discovered that when you run foundation watch you get the following error: Failed to load external module babel-register.

It follows that error with: Requiring external module babel-core/register

After that it runs as expected. This does not happen, when I clone a template, or when I simply run gulp from inside CLI project instead of foundation watch. Others report that it doesn't matter whether they run foundation watch or gulp, they still get the error.

My best guess for why this happens only on foundation watch with the CLI is because the foundation command is being run globally and it looks for babel-register there instead of locally on the first attempt to find it.

colin-marshall avatar Apr 12 '16 16:04 colin-marshall

I still get above errors when running gulp from inside CLI project folder.

ademers avatar Apr 12 '16 16:04 ademers

@ademers is this occurring on a fresh install of 6.2.1 via CLI?

colin-marshall avatar Apr 12 '16 16:04 colin-marshall

@colin-marshall On an existing install and on a new one created via foundation new --framework sites --template zurb command.

ademers avatar Apr 12 '16 16:04 ademers

The babel error appears on new projects installed with the CLI, regardless of the build command(foundation watch/npm start/gulp). It does not happen with manually downloaded projects.

realDaveLin avatar Apr 12 '16 23:04 realDaveLin

Updated the first post to reflect that for some people it doesn't matter what command is run.

colin-marshall avatar Apr 15 '16 01:04 colin-marshall

Getting this error too, I ran npm install babel-register --save-dev and it took care of not finding that package but I'm still getting this error:

/Users/Ryan/Sites/foundation6/gulpfile.babel.js:3
import plugins from 'gulp-load-plugins';
^^^^^^

SyntaxError: Unexpected reserved word
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:414:25)
    at loader (/Users/Ryan/Sites/foundation6/node_modules/babel-register/lib/node.js:126:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/Ryan/Sites/foundation6/node_modules/babel-register/lib/node.js:136:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at execute (/Users/Ryan/Sites/foundation6/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0-alpha.2/index.js:33:18)
    at Liftoff.handleArguments (/Users/Ryan/Sites/foundation6/node_modules/gulp/node_modules/gulp-cli/index.js:150:63)
Error: [email protected] start: `gulp`
Exit status 1
    at EventEmitter.<anonymous> (/Users/Ryan/.nvm/versions/node/v4.2.2/lib/node_modules/foundation-cli/node_modules/npm/lib/utils/lifecycle.js:217:16)
    at emitTwo (events.js:87:13)
    at EventEmitter.emit (events.js:172:7)
    at ChildProcess.<anonymous> (/Users/Ryan/.nvm/versions/node/v4.2.2/lib/node_modules/foundation-cli/node_modules/npm/lib/utils/spawn.js:24:14)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:818:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

Ryan-Harvey avatar Apr 17 '16 17:04 Ryan-Harvey

@Ryan-Harvey can you run gulp -v inside the project's root directory and paste the output here? Thanks!

colin-marshall avatar Apr 17 '16 22:04 colin-marshall

@colin-marshall Sure, here's the output:

[01:20:03] Requiring external module babel-core/register
[01:20:03] CLI version 3.9.0
[01:20:03] Local version 4.0.0-alpha.2

Ryan-Harvey avatar Apr 18 '16 00:04 Ryan-Harvey

Any update on this, @colin-marshall?

Ryan-Harvey avatar May 03 '16 14:05 Ryan-Harvey

@Ryan-Harvey there's a fix coming in 6.2.2 that should remove the require external module error. See https://github.com/zurb/foundation-sites/issues/8745, and additional changes will be made to the templates as well. Not sure if this will resolve your issue too. I'll shoot you a message when it's ready for you to test.

colin-marshall avatar May 08 '16 17:05 colin-marshall

I was having problems too. Turns out I had an old gulp-cli installed globally, but package.json points to gulp-cli 4.x. In other words, running gulp directly uses the global version, but running npm start (which launches gulp) uses the gulp version specified in package.json.

millette avatar May 15 '16 04:05 millette

@colin-marshall Gotcha, thanks!

Ryan-Harvey avatar May 15 '16 23:05 Ryan-Harvey

I do not get any errors but it just doesn't work. I have tried all the above but it just hangs right before it usually says ready on port 8080 or something to that effect.

jel111 avatar Jan 24 '17 03:01 jel111

@jel111 did you have it working before at one point? If so, were there any changes, like updating Node, that could have broke it?

colin-marshall avatar Jan 24 '17 21:01 colin-marshall

@colin-marshall no I have a new machine and didn't have foundation working on it yet so new installs all around. I just installed everything bare bones no frills. I checked and have everything needed installed but if you do not have it usually it lets you know. Noe of that. What's funny is if I go to my iMac and run it works. Something is diff I just have to find it. Thanks for the help everybody!

jel111 avatar Jan 25 '17 07:01 jel111

What version of Node are you running and what operating system are you on? Can you provide a log of the output when you run foundation watch please?

colin-marshall avatar Jan 25 '17 19:01 colin-marshall

I meet the same problem on windows. Don't know why but after waiting for a few minutes, it works.

aheinhoang avatar Dec 21 '17 08:12 aheinhoang