'gulp' is not recognized as an internal or external command
Asked Answered
C

13

85

I am trying to use Gulp and Node.Js to stream my process for minifying and concatenating CSS/JS files for production.

Here is what I have done.

  1. I installed Node.Js on my Windows 7 machine.
  2. Installed Gulp globally using this command npm install -g gulp
  3. Then I added a new User variable called NODE_PATH set it to %AppData%\npm\node_modules

After closing and re-opening my command line, I tried to run a gulp task from the command line (i.e. gulp css). But that give me the following error

'gulp' is not recognized as an internal or external command

How can I get this to work?

When I opened the following path using the search bar in windows, %AppData%\npm\node_modules I see the following two folders

gulp
gulp-cli

enter image description here

I've tried to add %AppData%\npm\node_modules to the Path variable on my system variable, but it did not take it because that variable reached it's max allowed character limit.

I removed couple of paths from my Path variable and added ;C:\Users\[MyWindowsUserName]\AppData\Roaming\npm\node_modules

but still not working.

I even tried to set the path at run time using this command

PATH=%PATH%;C:\Users\[MyWindowsUserName]\AppData\Roaming\npm\node_modules then run gulp and still the same issues.

What am I missing here? What else do I need in order to get this to work?

Crayfish answered 28/8, 2016 at 19:44 Comment(15)
When you echo $NODE_PATH do you get the correct path to the global node dependencies?Deannadeanne
when I type echo $NODE_PATH from the command line, it returns $NODE_PATHCrayfish
Sorry didn't read you were on win7. Try echo %PATH%Deannadeanne
And echo %NODE_PATH%Deannadeanne
typing echo %NODE_PATH% printed this %AppData%\npm\node_modulesCrayfish
And can you confirm that inside that folder (\npm\node_modules) there is gulp's folder?Deannadeanne
yes. I just added a screenshot of what is in that folderCrayfish
Okey maybe you could try the path manually. Going to My PC, right click -> properties -> Advanced settings -> environment variables. Then just add the new path to your users global path variable. It should work now.Deannadeanne
still now workingCrayfish
Well the last thing I can think of is vDeannadeanne
Not sure that I follow you. What is v?Crayfish
Did you restart windows (or just explorer)?Carney
I restarted my entire machine also but still not workingCrayfish
Do you have a gulp.cmd and gulp file in the Roaming\npm directory? I don't have any environment vars for gulp on my machine and gulp is working fineAnnunciata
Have you tried to reinstall it? npm uninstall -g gulpAnnunciata
C
73

I solved the problem by uninstalling NodeJs and gulp then re-installing both again.

To install gulp globally I executed the following command

npm install -g gulp
Crayfish answered 29/8, 2016 at 21:7 Comment(6)
To uninstall gulp using the follow command npm uninstall -g gulp. Then if you Windows, go to uninstall programs from the control panel and uninstall nodejsCrayfish
you don't have to uninstall anything. npm install -g gulp works like charm.Swanskin
Even after running this command, when I try gulp build, it gives me "'gulp' is not recognized as an internal or external command"Doug
Ran into this issue today. In my case, the problem is the mode I open the Visual Studio. I opened it in Administrator mode but then gulp was installed for my login (user) account. While the npm is added to the PATH environment variable, it is pointing to the user account which Administrator mode was unable to accesss. Once I re-installed gulp globally with -g, I was able to open the Gulp tasks as expected.Simarouba
This worked great! Did not have to uninstall locally for me.Describe
Worked like charm!Eddington
S
143

I had similar issue when I installed locally initially(w/o -g). I reinstalled with -g (global) and then it worked.

npm install -g gulp

you should run gulp from folder where gulpfile.js is available.

Slocum answered 8/11, 2016 at 21:7 Comment(1)
I still have the same issue even if I am in the npm folder, it's quite weird, the batch file glup.cmd is well in the folder. i am under Windows 10 21H1 and NodeJs 16.3Onondaga
C
73

I solved the problem by uninstalling NodeJs and gulp then re-installing both again.

To install gulp globally I executed the following command

npm install -g gulp
Crayfish answered 29/8, 2016 at 21:7 Comment(6)
To uninstall gulp using the follow command npm uninstall -g gulp. Then if you Windows, go to uninstall programs from the control panel and uninstall nodejsCrayfish
you don't have to uninstall anything. npm install -g gulp works like charm.Swanskin
Even after running this command, when I try gulp build, it gives me "'gulp' is not recognized as an internal or external command"Doug
Ran into this issue today. In my case, the problem is the mode I open the Visual Studio. I opened it in Administrator mode but then gulp was installed for my login (user) account. While the npm is added to the PATH environment variable, it is pointing to the user account which Administrator mode was unable to accesss. Once I re-installed gulp globally with -g, I was able to open the Gulp tasks as expected.Simarouba
This worked great! Did not have to uninstall locally for me.Describe
Worked like charm!Eddington
V
25

Go to My Computer>Properties>Advance System Settings>Environment Variables>

Under the variables of Administrator edit the PATH variable & change its value to "C:\Users\Username\AppData\Roaming\npm". Note: The username in the path will be the current Admin user's name that you have logged in with.

Vergeboard answered 3/7, 2017 at 11:50 Comment(1)
I solved this by editing the user path, since the %AppData%\npm is in the user directory (Windows Server 2016 Standard).Prothalamion
T
8

I had the same problem on windows 7. You must edit your path system variable manually.

Go to START -> edit the system environment variables -> Environment variables -> in system part find variables "Path" -> edit -> add new path after ";" to your file gulp.cmd directory some like ';C:\Users\YOURUSERNAME\AppData\Roaming\npm' -> click ok and close these windows -> restart your CLI -> enjoy

Takeshi answered 12/2, 2019 at 14:22 Comment(1)
Only solution that worked for me, on Windows 10, node-v10.16.3-x64, Visual Studio 2015. Thanks a lot.Augur
T
5

You may need to install the gulp-cli globally. Uninstall then re-install if you already have it:

npm uninstall -g gulp-cli

npm install -g gulp-cli

Tullis answered 18/5, 2021 at 0:43 Comment(0)
D
0

Sorry that was a typo. You can either add node_modules to the end of your user's global path variable, or maybe check the permissions associated with that folder (node _modules). The error doesn't seem like the last case, but I've encountered problems similar to yours. I find the first solution enough for most cases. Just go to environment variables and add the path to node_modules to the last part of your user's path variable. Note I'm saying user and not system.

Just add a semicolon to the end of the variable declaration and add the static path to your node_module folder. ( Ex c:\path\to\node_module)

Alternatively you could:

In your CMD

PATH=%PATH%;C:\\path\to\node_module

EDIT

The last solution will work as long as you don't close your CMD. So, use the first solution for a permanent change.

Deannadeanne answered 28/8, 2016 at 21:8 Comment(1)
nothing is working for me. I even took the full path and added it to the system Path variable and that did not workCrayfish
C
0

In my case, this problem occured because I did npm install with another system user in my project folder before. Gulp was already installed globally. After deleting folder /node_modules/ in my project, and running npm install with the current user, it worked.

Comedown answered 17/11, 2017 at 7:35 Comment(0)
S
0

You need to make sure, when you run command (install npm -g gulp), it will create install gulp on C:\ directory.

that directory should match with whatver npm path variable set in your java path.

just run path from command prompt, and verify this. if not, change your java class path variable wherever you gulp is instaled.

It should work.

Susa answered 25/4, 2018 at 19:35 Comment(0)
P
0

If you have mysql install in your windows 10 try uninstall every myqsl app from your computer. Its work for me. exactly when i installed the mysql in my computer gulp command and some other commands stop working and then i have tried everything but not nothing worked for me.

Plotkin answered 10/10, 2019 at 15:40 Comment(0)
G
0

I just encountered this on Windows 10 and the latest NodeJS (14.15.1). In my case our admins have our profiles and true "home" folder remotely mount onto our work machine(s). Npm wanted to put its cache over on the remote server and that has worked until this release.

I was unaware that npm has a .npmrc file available. I added one to my actual machine's C:\Users\my-id folder and it contains:

prefix=C:\Users\my-id\nodejs\npm
cache=c:\Users\my-id\nodejs\npm-cache

I also added these paths to my PATH environment variable.

I went to the APPDATA folder on my work machine and the remote "home" server and deleted all the npm related Roaming folders. I deleted the node_modules folder in my project.

I closed all open windows and reopened them. I brought up a command prompt in my project dir and re inited npm and reinstalled the modules I wanted.

After that everything is rolling along.

Gearard answered 10/12, 2020 at 22:10 Comment(0)
M
0

Just to add to @Vinod R's answer

Go to My Computer>Properties>Advance System Settings>Environment Variables>

Under the variables of Administrator edit the PATH variable & change its value to "C:\Users\Username\AppData\Roaming\npm". Note: The username in the path will be the current Admin user's name that you have logged in with.

After this, move the path to the top as shown in the image attached.

image for demostration

Maneating answered 21/6, 2022 at 13:46 Comment(0)
R
-1

I was having the same exception with node v12.13.1,

Downgraded node to v10.15.3 and it works fine now.

Richelieu answered 4/12, 2019 at 14:46 Comment(0)
A
-2

The best solution, you can manage the multiple node versions using nvm installer. then, install the required node's version using below command

nvm install version

Use below command as a working node with mentioned version alone

nvm use version

now, you can use any version node without uninstalling previous installed node.

Abatis answered 12/12, 2019 at 12:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.