Error: Requiring external module babel-register - gulp

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
Getting error when running gulp serve, I've fixed this before by removing the entire webapp repo from local. Any and all help/advice appreciated, also please forgive if I've not formatted this issue as correctly as possible(first issue ever opened). Would like to resolve this without having to do this. gulp serve throws the following:
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

I had a very similar issue with running a custom project that was originally created using the Yeoman Webapp generator and found a solution that worked for me. A bit of context... the project was running fine on my Windows 7 machine and when I tried to move it over to my Mac OSX machine I received the exact same error. What I found works is creating a new Yeoman Web App project and drag & dropping the exact node-modules folder structure over to your existing project. Most likely than not, there is a dev dependency that your machine is not reading and fetching accurately, in this case, the babel-register module which is contained within this node-modules folder.
If possible for you to do, it's also worth comparing the versions of node, npm, gulp, gulp cli with your previous working version and the version you are having trouble loading when running gulp serve to see if they match.

Related

local gulp not found after installing globally and locally

I have installed gulp both globally
sudo npm install --global gulp-cli
and locally
npm install --save-dev gulp
/usr/local/bin/gulp exists, and ./node_modules/gulp and ./node_modules/gulp-cli exist.
When I try to run gulp on the command line, I get the common error
$ gulp
[00:55:43] Local gulp not found in ~/dev/myProj/play-java-seed
[00:55:43] Try running: npm install gulp
One thing that I noticed is that if I run gulp in some random directory (~/foo), the error message is that the local gulp is not found in that directory. If I run it from the correct directory (~/dev/myProj/play-java-seed/ui) then the error references the parent directory.
There is in fact no gulp installed in the directory in the error message; it is installed on directory lower.
/usr/local/bin/gulp is a symlink to a file with these contents:
#!/usr/bin/env node
'use strict';
require('../')();
Is the .. in that file correct? It seems strange, but I have not looked at it closely before.
If the OS matters, I am running 32 bit Ubuntu 16.04.
devDependencies in my package.json includes both gulp and gulp-cli
Rico Kahler had the correct answer in his comment.
When I looked at the machine (instead of going off of my memory), I saw that the gulp file was one directory higher than it should have been.
The error message did have a clue toward this: it gave the directory holding the gulpfile, not the current directory.

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
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 gulp#3.9.0
hopefully it'll help you.
maybe this can help.
create .babelrc in your projects, and put this:
{
"presets": [
"es2015"
]
}
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
npm install babel-cli babel-preset-es2015
me helped when i deleted and again installed both same version as global as local in the project directory the gulp and deleted and reinstal the babel-register.
sudo npm uninstall -g gulp
npm uninstall gulp
sudo npm install -g gulp#3.9.0
npm install gulp#3.9.0
npm uninstall babel-register
npm install babel-register

what does gulp-"cli" stands for?

Can someone please explain what exactly are the differences between the following two methods of gulp installation:
$ npm install --global gulp-cli
and
$ sudo npm install -g gulp
It looks to me that both do the same thing except that the first method gives me a version 1.2.1, and the later gives me version 3.9.1
Can someone put into simple terms what exactly are the differences? and plus what is "cli" stands for?
The goal of gulp-cli is to let you use gulp like a global program, but without installing gulp globally.
For example if you installed gulp 3.9.1 globally and your project testGulp4 has gulp 4.0 installed locally, what would happen if you run gulp -v into testGulp4?
Without gulp-cli globally installed :
CLI version 3.9.1
In this case the version displayed is the global version of gulp. The local version 4.0 is totally ignored.
With gulp-cli globally installed :
CLI version 1.2.1
Local version 4.0.0-alpha.2
In this case the version displayed is the global version of gulp-cli and the local version of gulp. The global gulp 3.9.1 is totally ignored.
Conclusion :
gulp-cli: is preferred because it allows you to use different versions of gulp.
gulp: needs a local version of gulp installed.
CLI stands for Command Line Interface.
gulp is a JavaScript library. It lets you use gulp from JavaScript code.
gulp-cli is a utility program that lets you access gulp from your shell.

Mismatch in gulp local and CLI versions

I had previously installed gulp globally using npm install gulp -g. Then I cloned an existing project, and that required me to use its own gulp. Now when I do a gulp -v from outside my project folder, I get a mismatch like this.
C:\Users\userme>
[11:14:05] CLI version 3.8.11
[11:14:05] Local version 1.0.0
And when I do a gulp from my project folder, I get this.
C:\project\new\tools>
[11:14:26] CLI version 3.8.11
[11:14:26] Local version 3.8.11
Now I have not been able to merge my JS files properly using gulp (I'm getting some weird formatting errors in the min file) and I suspect it has something to do with this mismatch.
Is there a way to remove the global gulp version, but keep the project specific gulp?
Or can I update my global version gulp to #3.8.11?
Note - I did try updating the global gulp by using npm update gulp#3.8.11 -g but nothing happened. i still get the mismatch.
Update to describe the issue:
I am using gulp to merge multiple JS files into 1 single main.js file. The formatting that I get in the merged file has a syntactical error in it.
Expected output in merged file -
...
define('utils/knockoutBindings/slider',['require','ko','jquery'],function(require) {
'use strict';
var ko = require('ko');
var $ = require('jquery');
...
Actual output in merged file (this 1 line of code below is wrongly replacing the entire 4 lines above) -
...
var'utils/knockoutBindings/slider',['require','ko','jquery'],function(require) {
...
It might seem that there is an issue in the gulp code, but the same code is used by other users and it works well on their end. The only difference we have found is in the mismatch in my gulp versions.
I am answering my own question, just so it is useful for others.
Is there a way to remove the global gulp version, but keep the project specific gulp?
No. AFAIK, you are required to install gulp globally as well as one specific to your project.
More info on gulp versions here.
Why do we need to install gulp globally and locally?
http://blog.dwaynecrooks.com/post/110903139442/why-do-we-need-to-install-gulp-globally-and
https://github.com/gulpjs/gulp/issues/171
https://github.com/gulpjs/gulp/issues/140
Or can I update my global version gulp to #3.8.11?
Since I was facing a mismatch in my local version, I had to update it from the project folder itself.
npm install gulp#3.8.11 --save
More info on this here.
http://www.eskocruz.com/gulp-version-mismatch
To update your Local version npm install gulp#version_you_need
To update CLI version npm install -g gulp#version_you_need
Removing node_modules folder and running npm install gulp within that dir sorted my issue out.
npm install -g gulp wasn't fixing it for me, from either in or out of the project folder. My gulp version was already correct in my package.json file. All I had to do was run npm install from within the project folder, and the gulp version from in the project folder was corrected.
Updating both the local version same as that of the global version fixed the issue. My initial gulp -v yielded CLI version 3.9.1 and Local version 4.0.0. I updated the local version from within the project folder npm install gulp#3.9.1 --save. This resolved my issue .
Gulp 4 uses an updated CLI which needs to be updated globally. This CLI is backwards compatible with any Gulp 3.X projects you may have locally - Read more.
It seems that the latest version (at the time of this post) of gulp-cli is 2.3.0 which means there will always be a mismatch.
If you run npm install -g gulp, then the latest version of the CLI will be installed. If you have any other version installed then it will update to the latest version.
The local version's latest release (at the time of this post) is 4.0.2.
Run npm install --save-dev gulp to install the latest version of Gulp in your project folder as a dev-dependency. Like with the CLI version it will update if you have an older version.
Mismatched versions work like normal.
SIDE NOTE: Remember to prefix global installs with sudo if you're working on a Mac and you have admin rights e.g. sudo npm install -g gulp.
BUT if you don't have admin rights and you can update the local version, but not the global version, then you can run node ./node_modules/gulp/bin/gulp.js from your project folder and it will execute the gulp file, even if you have the wrong CLI version, but you need to have the default task set up.

can I run the hello.js example for spookyjs on nitrous.io?

Here are the exact steps I took to try to run the hello.js example for spooky js on nitrous.
1. I installed phantomjs, nodejs(already installed), and casperjs.
$ npm install -g casperjs
Casper warns me that While CasperJS is installable via npm, it’s not a NodeJS package, neither it’s capable to require native NodeJS modules.
Because of this I wanted to use spookyjs which is a nodejs package.
Then, I installed phantom js: $ npm install phantomjs
Finally, I installed spookyjs: $ npm install spooky
2. I tried running the hello.js example using
$ node node_modules/spooky/examples/hello.js
3. I end up getting this error:
{ [Error: Child terminated with non-zero exit code 1] details: { code: 1, signal: null }}
Am I doing something wrong or can casperjs not be installed?
this is where I found spookyjs
Have you installed the phantomjs and casperjs runtime? The npm packages for phantomjs and casperjs call out to these runtimes. The error you see is when it can not find the casperjs runtime.
I'm not very familiar with nitrous.io and how much freedom you have to install other runtimes. Here's what I used for installing them on Linux: https://www.dvdheiden.nl/2013/07/30/installing-phantomjs-and-casperjs-on-linux/