Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After installation of Gulp: “no command 'gulp' found”

After installing gulp.js via npm, I receive a no command 'gulp' found error when running the gulp command from the same directory it was installed into.

When looking under the node_modules/.bin/ directory, I can see the gulp executable there.

Is there something wrong with my npm installation?

like image 832
AndrewMcLagan Avatar asked Mar 06 '14 12:03

AndrewMcLagan


People also ask

Why is gulp command not found?

To solve the error "gulp: command not found", install the gulp-cli package globally by running npm install -g gulp-cli and restart your terminal. If the command fails, run it with sudo and make sure the correct PATH is set in your system's environment variable.

How do I know if gulp is installed?

First run npm -g install gulp-cli then run gulp -v. Alternatively, you can just run npm list gulp.

Where does gulp get installed?

The global npm directory is where your packages get installed when you install them globally. You can check where it is by typing in npm root -g in the command line. For Mac users, if the root command returns a directory like /Users/YOURNAME/node_modules then this will cause the command not found error.


1 Answers

That's perfectly normal. If you want gulp-cli available on the command line, you need to install it globally.

npm install --global gulp-cli 

See the install instruction.

Also, node_modules/.bin/ isn't in your $PATH. But it is automatically added by npm when running npm scripts (see this blog post for reference).

So you could add scripts to your package.json file:

{     "name": "your-app",     "version": "0.0.1",     "scripts": {         "gulp": "gulp",         "minify": "gulp minify"     } } 

You could then run npm run gulp or npm run minify to launch gulp tasks.

like image 108
Brian Clozel Avatar answered Oct 09 '22 15:10

Brian Clozel