Reputation: 325
I'm trying to use gulp on my Vagrant machine (Ubuntu box), and therefore installed it like this:
sudo apt-get install nodejs npm
sudo npm install -g gulp
But upon trying gulp -v I got this:
vagrant@laravel:/var/www$ gulp -v
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'optimist'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/usr/local/lib/node_modules/gulp/bin/gulp:4:10)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:41)
So I additionally ran sudo npm install -g optimist
. The above error was solved, but now I'm stuck with this:
vagrant@laravel:/var/www$ gulp -v
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: undefined is not a function
at /usr/local/lib/node_modules/gulp/bin/gulp:26:12
at Array.filter (native)
at getGulpFile (/usr/local/lib/node_modules/gulp/bin/gulp:25:6)
at Object.<anonymous> (/usr/local/lib/node_modules/gulp/bin/gulp:8:18)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:41)
Any ideas? Thank you!
PS. These are the versions running:
vagrant@laravel:/var/www$ node -v
v0.6.12
vagrant@laravel:/var/www$ npm -v
1.1.4
Upvotes: 2
Views: 1324
Reputation: 4389
Your NodeJS
version is too old. This could very well be the problem, Gulp
seems to run only on >= 0.9
.
This is due to the apt-get
package being quite out of date, you can get the newest version with this Vagrant script:
config.vm.provision :shell, inline: "sudo add-apt-repository ppa:chris-lea/node.js"
config.vm.provision :shell, inline: "sudo apt-get update"
config.vm.provision :shell, inline: "sudo apt-get install -y nodejs --no-install-recommends"
A example of a working Vagrant file with the newest node can be found here.
There are other ways of getting the newest Node
version, but this one should work.
Upvotes: 1