google / web-starter-kit

Web Starter Kit - a workflow for multi-device websites
http://developers.google.com/web/starter-kit
Apache License 2.0
18.43k stars 3.02k forks source link

Requiring external module babel-core/register #878

Closed cesards closed 7 years ago

cesards commented 8 years ago

I have read all the closed issues related, but there is no way to fix the problem:

Once I download the web-starter-kit and I run npm install, and then I try to serve the repo running gulp serve but I get:

/Users/cdi08/workspace-github/SiteCesards/gulpfile.babel.js:27
import path from 'path';
^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:513:28)
    at loader (/Users/cdi08/workspace-github/SiteCesards/node_modules/babel-register/lib/node.js:158:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/cdi08/workspace-github/SiteCesards/node_modules/babel-register/lib/node.js:168:7)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)

Running gulp -v I get the following:

[10:35:50] Requiring external module babel-core/register
[10:35:50] CLI version 3.9.0
[10:35:50] Local version 3.9.1

Then I've tried many things, as

sudo npm install babel-register
sudo npm install babel-core

and also trying to downgrade the gulp version:

npm install -g gulp@3.9.0

I get nothing.

Last I tried was

npm install --save-dev babel-register

but I get the following error:

npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save-dev" "babel-register."
npm ERR! node v6.3.0
npm ERR! npm  v3.10.3
npm ERR! code E404

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/babel-register.
npm ERR! 404
npm ERR! 404  'babel-register.' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Any thoughts? Thank you!

thecreation commented 8 years ago

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.

mikeritter commented 8 years ago

same issue on win 10

ghost commented 7 years ago

@cesards I had the same issue and solved it after adding the missing .babelrc file with the following content:

{
  "presets": ["es2015"],
  "retainLines": true
}
GavinSong123 commented 7 years ago

same issue on ubuntu 16.04 and aftering adding content to .babelrc, it has not been solved.

mikeritter commented 7 years ago

I went back and reviewed the installation instructions in the README file. I had skipped a step there. Be sure to go back and do that.

cesards commented 7 years ago

Thanks @luc-baro . It works!! It's just adding the .babelrc file to the root of the folder.

lisawilkins commented 7 years ago

I've run through all the open and closed issues pertaining to this, tried all of the various fixes, uninstalls, installs, code changes, running older versions of gulp, repo tossing & reinstalling and am still getting ...

Requiring external module babel-core/register
mpavel commented 7 years ago

Go to babel website, Installation section, and select "Gulp" - http://babeljs.io/docs/setup/#installation

Take a look at step 4 - you will need to create a .babelrc configuration file and use a babel-preset. This resolved the issue for me.

jaenlasan commented 3 years ago

I just solved the problem by changing the name of the file .babelrc to .babelrc.json. I hope this help you out

Stevemoretz commented 3 years ago

@cesards I had the same issue and solved it after adding the missing .babelrc file with the following content:

{
  "presets": ["es2015"],
  "retainLines": true
}

The second line made my setup pretty fast thank you!