I installed gulp(globally) and it looks like it worked because it ran this code:
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected] ([email protected], [email protected], [email protected])
+-- [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
+-- [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
+-- [email protected] ([email protected], [email protected], [email protected], [email protected])
+-- [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
But when I type gulp
it says -bash: gulp: command not found
Any idea what's going on?
In my case adding sudo before npm install solved gulp command not found problem
sudo npm install
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 use sudo
, so I like to have it in my user dir. You can check your prefix with npm prefix -g
.
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:
npm config set prefix /usr/local
I confirmed the npm root -g
was pointing to /usr/local/lib/node_modules/npm
, but in order to install gulp
in /usr/local/lib/node_modules
, I had to use sudo
:
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.
sudo
npm config get prefix
/usr/local
/usr
or /Users/YOURUSERNAME/node_modules
or /Something/Else/FishyLooking
npm config set prefix /usr/local
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
Now you should be able to run npm <whatever>
without sudo
. Note: You may need to restart your terminal in order for these changes to take effect.
I had this problem with getting "command not found" after install but I was installed into /usr/local as described in the solution above.
My problem seemed to be caused by me running the install with sudo. I did the following.
If you're using tcsh
(which is my default shell on Mac OS X), you probably just need to type rehash
into the shell just after the install completes:
npm install -g gulp
followed immediately by:
rehash
Otherwise, if this is your very first time installing gulp
, your shell may not recognize that there's a new executable installed -- so you either need to start a new shell, or type rehash
in the current shell.
(This is basically a one-time thing for each command you install globally.)
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 are on Mac run use root privilege
sudo npm install gulp-cli --global
To check if it's installed run
gulp -v
CLI version: 2.2.0 (The output)
Local version: Unknown
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!!
I got this working on Win10 using a combination of the answers from above and elsewhere. Posting here for others and future me.
I followed the instructions from here: https://gulpjs.com/docs/en/getting-started/quick-start but on the last step after typing gulp --version I got the message -bash: gulp: command not found
To fix this:
Also, found the below for reasons why not to install gulp globally and how to remove it (not sure if this is advisable though):
Source: Stackoverflow.com