Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with gulp serve: Requiring external module babel-register

Running yeoman generator "Webapp", I'm getting an error when running gulp serve. Here are the following versions for a better background :

sw_vers && node -e 'console.log(process.platform, process.versions)'
ProductName:    Mac OS X
ProductVersion: 10.11.3
BuildVersion:   15D21
darwin { http_parser: '2.6.0',
  node: '5.2.0',
  v8: '4.6.85.31',
  uv: '1.7.5',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  icu: '56.1',
  modules: '47',
  openssl: '1.0.2e' }

node -v
v5.2.0

gulp -v
Requiring external module babel-register
CLI version 3.9.1
Local version 3.9.1

Finally the gulp serve error:

gulp serve
Requiring external module babel-register
\node_modules/babel-core/lib/transformation/file/options/option-manager.js:372
      throw new Error("Couldn't find preset " + JSON.stringify(val) + "      relative to directory " + JSON.stringify(dirname));

Does anybody have any idea what the problem could be, any suggestions?

Here's what I've tried:

npm uninstall gulp 
npm install gulp 
//with global flag and not
npm install --save-dev gulp 
//installing babel-register manually w/wo global flag and --save-dev
npm install babel-register
npm cache clean

Also read through several of other posts with similar problem with no success, some of the following :

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

Requiring external module babel/register #726

babel was renamed to babel-core #727

Angular-Fullstack Requiring external module babel-register

like image 836
alphapilgrim Avatar asked Mar 06 '16 21:03

alphapilgrim


3 Answers

yep, after running npm install --global gulp-cli I run gulp -v and I’ve got

Failed to load external module babel-register
Requiring external module babel-core/register
CLI version 1.2.1
Local version 3.9.1

then I updated CLI version to 3.9.1 (same as I have locally) but it did not help. but when I downgrade CLI version to 3.9.0 it started work correct and message “Failed to load external module babel-register” not shown anymore. Looks like 3.9.1 is buggy. Run:

npm install -g [email protected]

hopefully it'll help you.

like image 117
Roman Marshevskyy Avatar answered Nov 13 '22 19:11

Roman Marshevskyy


maybe this can help.

create .babelrc in your projects, and put this:

{
  "presets": [
    "es2015"
  ]
}
like image 22
dehamzah Avatar answered Nov 13 '22 19:11

dehamzah


I have tried many ways explaining above, including

npm install --global gulp
npm install --save-dev gulp 

etc for installation of gulp, but finally found solution by running below command, which change gulp to something gulp-cli on phpStorm command line.

npm install -D babel
like image 1
Abdullah Muhammad Avatar answered Nov 13 '22 21:11

Abdullah Muhammad