I installed gulp(globally) and it looks like it worked because it ran this code:
├── tildify@0.2.0
├── interpret@0.3.5
├── pretty-hrtime@0.2.1
├── deprecated@0.0.1
├── archy@0.0.2
├── minimist@0.2.0
├── semver@2.3.2
├── orchestrator@0.3.7 (stream-consume@0.1.0, sequencify@0.0.7, end-of-stream@0.1.5)
├── chalk@0.5.1 (escape-string-regexp@1.0.1, ansi-styles@1.1.0, supports-color@0.2.0, strip-ansi@0.3.0, has-ansi@0.1.0)
├── gulp-util@2.2.20 (lodash._reinterpolate@2.4.1, dateformat@1.0.8-1.2.3, vinyl@0.2.3, through2@0.5.1, multipipe@0.1.1, lodash.template@2.4.1)
├── liftoff@0.12.0 (extend@1.2.1, minimist@0.1.0, resolve@0.7.4, findup-sync@0.1.3)
└── vinyl-fs@0.3.5 (graceful-fs@3.0.2, lodash@2.4.1, mkdirp@0.5.0, strip-bom@0.3.1, vinyl@0.2.3, through2@0.5.1, glob-watcher@0.0.6, glob-stream@3.1.14)
But when I type gulp
it says -bash: gulp: command not found
Any idea what's going on?
Not sure why the question was down-voted, but I had the same issue and following the blog post recommended solve the issue. One thing I should add is that in my case, once I ran:
I confirmed the
npm root -g
was pointing to/usr/local/lib/node_modules/npm
, but in order to installgulp
in/usr/local/lib/node_modules
, I had to usesudo
:sudo npm install gulp -g
I realize that this is an old thread, but for Future-Me, and posterity, I figured I should add my two-cents around the "running npm as sudo" discussion. Disclaimer: I do not use Windows. These steps have only been proven on non-windows machines, both virtual and physical.
You can avoid the need to use sudo by changing the permission to npm's default directory.
How to: change permissions in order to run npm without
sudo
Step 1: Find out where npm's default directory is.
npm config get prefix
Step 2: Proceed, based on the output of that command:
/usr/local
For most users, your output will show that npm's default directory is /usr/local, in which case you can skip to step 4 to update the permissions for the directory.
/usr
or/Users/YOURUSERNAME/node_modules
or/Something/Else/FishyLooking
If you find that npm's default directory is not /usr/local, but is instead something you can't explain or looks fishy, you should go to step 3 to change the default directory for npm, or you risk messing up your permissions on a much larger scale.
Step 3: Change npm's default directory:
npm config set prefix /usr/local
Step 4: Update the permissions on npm's default directory:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
Now you should be able to run
npm <whatever>
withoutsudo
. Note: You may need to restart your terminal in order for these changes to take effect.You need to do this
npm install --global gulp
. It works for me and i also had this problem. It because you didn't install globally this package.If you want to leave your prefix intact, just export it's bin dir to your PATH variable:
export PATH=$HOME/your-path/bin:$PATH
I added this line to my $HOME/.profile and sourced it.
Setting prefix to
/usr/local
makes you usesudo
, so I like to have it in my user dir. You can check your prefix withnpm prefix -g
.I had similar problem I did the following steps and it worked.Go to mac terminal and execute the commands,
1.npm config set prefix /usr/local
2.sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
This two commands will set the npm path right and you no longer have to use sudo in npm. Next uninstall the gulp
npm uninstall gulp
Installl gulp again without sudo, npm install gulp -g
This should work!!