235

I've installed gulp both globally and locally using

npm install gulp
npm install gulp -g
npm install gulp-util
npm install gulp-util -g

When try to run gulp i get

'gulp' is not recognized as an internal or external command, operable program or batch file.

Running npm list gulp (or -g), I gulp@3.7.0 with the location of either my global or local gulp installation.

I've tried running node gulpfile.js pointed to my gulpfile, and it runs without error, and of course, it starts with require('gulp').

Any suggestions on getting gulp working on Windows(8.1)?

pedalpete
  • 19,318
  • 41
  • 115
  • 225
  • 1
    I'm not using gulp on windows, but have you tried `npm install gulp --save-dev` ? – soenguy Jun 04 '14 at 07:08
  • 2
    @soenguy that will not solve it – SteveLacy Jun 04 '14 at 16:21
  • @pedalpete did my answer solve your question? Please mark it if so – SteveLacy Dec 15 '15 at 19:11
  • I was having this issue until I removed node.js COMPLETELY and reinstalled/restarted my computer. I was getting all sorts of weird errors from my node plugins. –  Jun 09 '18 at 15:12
  • I encountered this problem recently: turns out the only thing that I forgot was to add the folder where the executable `gulp` program lies to the Windows %PATH% variable. In my case: `%AppData%\Roaming\npm` – AdrienW Sep 24 '18 at 14:10
  • This will solve the problem https://stackoverflow.com/a/45707907/5222115 – murtuza hussain Nov 30 '18 at 12:36
  • If you're on Windows and gulp is not recognized as an internal or external command, operable program or batch file try running gulp.js instead. I'm working on a laravel project, and running gulp locally. Also use something other then Windows command prompt, because you will probably get an error with gulp.js. I am using Git bash, and it works perfectly. – Peter Szalay Oct 22 '19 at 12:37
  • On my side, it was a "permission to run script" that was not enabled on my computer. Source : http://www.octetmalin.net/windows/scripts/powershell-activer-execution-des-scripts.php (french) Had to run ` set-executionpolicy unrestricted ` in the powershell in admin mode to fix the issue. – Patrice Poliquin Oct 23 '19 at 13:51

40 Answers40

247

You forgot to install the gulp-cli package:

npm install -g gulp-cli

Then you can run the command "gulp" from the command line.

csnate
  • 2,549
  • 1
  • 11
  • 3
  • Yeah, after the registery change didn't work this did the trick : ' ) – edencorbin May 19 '16 at 21:19
  • This piece wasn't even included in our artifactory to grab, so couldn't get it to install it. – vapcguy Oct 06 '17 at 15:21
  • This fixed the problem for the "Learn Bootstrap 4 Final in 2018 with our Free Crash Course" tutorial. I will put a link to this answer in that guys tutorial for others who might have the same problem – Enrique Bruzual Feb 23 '18 at 10:07
225

The issue and answer can be found in this question: https://stackoverflow.com/a/9588052/1041104

The npm modules such as gulp are not installed to the path. Thus are not found when you run them in the CMD.

If gulp has been installed globally, you can use the process below:

  1. Create an environmental variable called NODE_PATH
  2. Set it to: %AppData%\npm\node_modules or %AppData%\npm on windows 8-10
  3. Close CMD, and Re-Open to get the new ENV variables

Add Node path to environmental variables

Running npm ls and npm ls -g shows that they are installed, but the CMD can not find them due to the missing link.

Community
  • 1
  • 1
SteveLacy
  • 3,910
  • 2
  • 21
  • 29
  • 15
    I think that it's important to note, however, that the answer provided DOES NOT WORK if gulp has not been installed globally. the %AppData%\npm folder is completely empty on initial installation and if you only install gulp in a project folder without using -g, it doesn't put the batch file in \npm\ or its files in \npm\node_modules . So in reality BOTH answers here are necessary. – Évelyne Lachance Jul 29 '15 at 03:28
  • 8
    I tried this and it still didn't work for me until I realised my "Path" environment variable name was in camel case and not "PATH" (in upper case). I modified "Path" to "PATH" and added my npm directory to the beginning as in @CIAODO 's answer. For some reason "%AppData%\Roaming\npm didn't work for me so I had to use the full path: "C:\Users\\[user.name]\AppData\Roaming\npm;". Combined with this answer it worked for me. – R Brill Nov 12 '15 at 09:23
  • %AppData%\Roaming\npm didn't work for me too, also had to use the full path: "C:\Users\[user.name]\AppData\Roaming\npm;" – user2345998 Nov 25 '15 at 08:43
  • 34
    adding %AppData%\npm to PATH worked for me (Windows 10) – outofBounds May 25 '16 at 08:32
  • I tried this but it didn't work but after I restarted my pc, it worked. Don't know what happened. – lyhong Dec 15 '16 at 03:41
  • @outofBounds that worked for me as well on win10, whereas the other steps did not. gulp had been working fine for me until today, not sure what changed. – Steve Scheffler Jan 03 '17 at 18:50
  • If you're using the terminal Git Bash, it's not aware of %AppData%\Roaming\npm but instead I added this to ~/.bash_profile: export PATH=$PATH:/c/Users/MyUsername/AppData/Roaming/npm and it found gulp after doing: source ~/.bash_profile – phpguru Apr 21 '17 at 16:15
  • @phpguru you are telling me that windows now supports only half of bash? lol! Thanks for commenting, if others have the same issue I'll add it to my answer. – SteveLacy Apr 25 '17 at 20:02
  • Can use the [`setx`](https://superuser.com/a/79614/292784) command to achieve it; `setx NODE_PATH %AppData%\npm` (Windows 10). And I realized I didn't have the necessary packages installed globally, so be sure to use the `npm install -g ` to populate the `node_modules` folder in the `NODE_PATH` – The Red Pea Apr 28 '17 at 18:39
90
  1. Be sure that you have gulp and gulp.cmd (use windows search)
  2. Copy the path of gulp.cmd (C:\Users\XXXX\AppData\Roaming\npm)
  3. Add this path to the Path envirement variable or edit PATH environment variable and add %APPDATA%\npm
  4. Reopen cmd.

Add %APPDATA%\npm to front of Path, not end of the Path.

H. Pauwelyn
  • 11,346
  • 26
  • 71
  • 115
Habib Adıbelli
  • 1,141
  • 7
  • 14
  • 7
    Add %APPDATA%\npm to front of Path, not end of the Path. – Habib Adıbelli Dec 04 '14 at 14:02
  • Thank you @CIAODO! my path had crap from an earlier node install for testing purposes and you comment helped me track it down.`:) – Edward Aug 12 '15 at 15:26
  • It just stopped working for me suddenly, I think after I changed some other PATH variables. Your first solution was the only one that worked for me. Thanks. – Martin Dawson Apr 30 '16 at 22:42
45
  1. Install gulp globally.

    npm install -g gulp

  2. Install gulp locally in the project.

    npm install gulp

  3. Add below line in your package.json

    "scripts": { "gulp": "gulp" }

  4. Run gulp.

    npm run gulp

This worked for me.

ketan
  • 17,717
  • 41
  • 50
  • 83
Gaurav Goel
  • 551
  • 4
  • 2
  • After doing Step 4, it did not run for me - it just returned back another command line prompt after doing nothing (visible, at least). If I did just `gulp` after that, then it ran. – vapcguy Oct 06 '17 at 15:45
  • Brilliant. This was the solution to my failing build process that relied on Gulp in AppVeyor . Rather, I used something like `"package": "gulp build"`. – Crayons Nov 17 '17 at 07:30
32

I am using Windows 8.1. I had the same problem.

I installed gulp using Node.js command prompt

npm install -g gulp

Then go to the required directory in Node.js command prompt and try

gulp -v

If you get gulp local version not found exit the current Node.js command prompt and try the above command in a new Node.js command prompt

I tried the NODE_PATH mentioned by @SteveLacy but the command prompt was still not able to detect gulp command

Sudarsan GP
  • 1,124
  • 14
  • 21
27

Had the same problem, not really best solution but install it globally:

npm install -g gulp

Of course it's best to still have it in package.json, so you can do the following to install it locally and add an entry into package.json:

npm install --save-dev gulp

Everything else (gulp plugins) install also locally.

Namek
  • 1,155
  • 1
  • 13
  • 27
20

The simple solution just do npm link gulp

miojamo
  • 721
  • 2
  • 14
  • 30
19

I was having the same problem when trying to get gulp working on a co-workers VM. It seems the problem stems from the users folder.

Adding NODE_PATH in my environment variables didn't fix the problem.

If you edit your 'Path' variable in your system variables and add '%APPDATA%\npm' at the end of that, it should fix the problem... Unless you or somebody else npm installed gulp as another user than the one you're currently logged in as.

If you want it to be available for all users, put 'C:\Users\yourUser\AppData\Roaming\npm'(or where ever you have gulp) explicitly instead of using '%APPDATA%\npm'. You can also move the files to a more user-indifferent path.

Don't forget to start a new cmd prompt, because the one you have open won't get the new 'Path' variable automatically.

Now 'gulp'.

Spaceman
  • 191
  • 1
  • 4
16

One right way:

  1. Cmd + R : type "%appdata%"
  2. Go to npm folder
  3. Copy whole path like "C:\Users\Blah...\npm\"
  4. Go to My Computer + Right Click "Properties"
  5. Advanced System Settings (On the left)
  6. Click on Environment Variables
  7. Click on Edit Path
  8. Add that "C:\Users\Blah...\npm\" to the end and type ";" after that
  9. Click ok and reopen cmd
Koert van Kleef
  • 710
  • 9
  • 16
yeralin
  • 1,187
  • 11
  • 19
14

You should first install gulp as global using:

npm install gulp -g

Otherwise the path solution will not resolve the problem.

Then add the npm modules path to the PATH using:

PATH = %PATH%;%APPDATA%\npm
Jonathan Leffler
  • 666,971
  • 126
  • 813
  • 1,185
Badr Bellaj
  • 6,763
  • 1
  • 29
  • 30
  • Is the information you've added new and distinctly different from what the other 33 answers give? My impression is 'No', in which case, you probably shouldn't have added the answer. – Jonathan Leffler Jan 01 '17 at 23:42
  • 1
    I've tried many of them without success and i've figured out the need to install gulp globaly so to avoid anyone else the same pain i've added this answer – Badr Bellaj Jan 02 '17 at 11:06
14

In my case it was that I had to install gulp-cli by command npm -g install gulp-cli

Skylin R
  • 1,312
  • 1
  • 15
  • 22
9

Try to add to your PATH variable the following:

C:\Users\YOUR_USER\AppData\Roaming\npm

I had the same problem and I solved adding the path to my node modules.

JC Gomez
  • 101
  • 1
  • 2
9

I had a similar problem setting it up in windows 10. My answer is windows specific (look at the answers for modifying path in bash for a linux or OSX solution)

The core problem I had was that npm's folder was not registered in the path. I originally tried changing this in cmd prompt.

setx path "%path%;%appdata$\npm"

Note that I used setx instead of set to ensure that the update to the environmental variable remains. Also note that it's a backslash.

This should work but for me it didn't because setx has a limit of only accepting 1024 characters... (yes it's nonsensical to me as well).

So try the above and if you get a warning like did about reaching the 1024 limit, then you can do the other way I ended up doing.

First while youre still in the console, type: echo %appdata%\npm ... this is your npm folder that you want to add to the path so add it to your clipboard.

You have to go into the registry and reach the following folder:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Then append the 'Path' value with the npm folder path in your clipboard. Reboot to activate the new value and you should now be good to go.

using regedit

Finally, just test it all out

>npm install -g gulp
>gulp
ThinkBonobo
  • 12,631
  • 8
  • 48
  • 68
  • 1
    Yes!!! Finally! I have looked all over for something to help. Almost all of the answers say to install it globally and it should work. I've installed, uninstalled, reinstalled, cleared cache, etc. At last, this worked. Thank you! – Josh May 06 '16 at 05:53
  • @Josh, glad I could get you running. Setting up an environment is a b*tch. I think I switched over to mac mostly because of these little quirks when using windows shell. – ThinkBonobo May 06 '16 at 15:35
  • The worst part is that I've had it set up for months. It's been running fine. Then I'm programming one day and my commands aren't recognized. I search the Internet for anything that will help. Everyone says the same thing. Then you come along and BAM! It works. I understand why you would switch to OSX. I've never had these kind of quirks with OSX before. But I'm too committed to Windows. – Josh May 09 '16 at 05:57
  • 1
    well to your benefit, I believe windows 10 is adopting native bash shell. Should make life a LOT easier for some of these tools. – ThinkBonobo May 09 '16 at 14:45
  • This work for me in Windows Server 2008, thank you so much! – manix Jan 05 '17 at 23:01
6

This ended up being a 'user' issue with me. I had installed npm and node on the system logged in as user1, then I set-up user2. I could run node, and I could run npm commnds, but could not run any npm packages from the command line.

I uninstalled node and npm, and reinstalled under the correct user in order to solve the problem. After that I can run packages from the command-line without issue.

pedalpete
  • 19,318
  • 41
  • 115
  • 225
6

The top answer did not work for me.

I am using a virtual machine that had a previous owner. The previous owner had an old version of npm installed. Using that, I was installed gulp globally with npm install -g gulp. Running the command gulp would return 'gulp' is not recognized as an internal or external command, operable program or batch file.. As I said, the top Answer did not fix my problem. I basically had to reinstall nodejs.

Solution

  1. Re-download nodejs
  2. npm install -g gulp
  3. gulp -version

This fixed the problem for me.

christo8989
  • 5,064
  • 4
  • 27
  • 36
4

I had v0.12.3 of Nodejs on Win7 x64 and ran into similar issues when I tried installing gulp. This worked for me:

  1. Uninstalled Nodejs
  2. Installed Nodejs v0.10.29
  3. npm install -g npm
  4. npm install -g gulp
kmxr
  • 409
  • 2
  • 4
4

The NodeJS installer appears to add the user/AppData/Roaming/npm path to the user environment path, which is appropriate.

Normally, the PATH environment variable at the command line is the combination of the user environment path and the system environment path.

However, if the user environment path + the system environment path is larger than about 1920 characters, Windows does not not combine the user and system paths - only the system environment path is used.

See: https://stackoverflow.com/a/21270921/301152

So, when you open the Advanced System Settings in Windows to edit your environment variables, take a look to see if the user/AppData/Roaming/npm path is already in your user environment PATH. If it is, then the problem is that your user + system paths are too long, causing Windows to ignore your user path. Trim your user and/or system path strings and gulp should work as installed.

If you can't find anything to trim away from your user and system paths, then add the user/AppData/Roaming/npm path to the system environment path and call it a hack.

Community
  • 1
  • 1
dthorpe
  • 33,791
  • 3
  • 72
  • 118
  • 1
    I have spent hours trying to get the gulp command working in windows, and this was what finally worked for me. So thank you! – MyNotes Mar 16 '16 at 14:01
4

I was facing the same problem after installation. So i tried running cmd with elevated privileges (admin) and it worked.

Screen capture:

cmd

Rohit416
  • 3,114
  • 3
  • 21
  • 38
Amit Sharma
  • 143
  • 1
  • 7
4

Add this path in your Environment Variables PATH C:\Users\USERNAME\AppData\Roaming\npm\

Kranti123
  • 189
  • 2
  • 2
  • 14
4

(Windows 10) I didn't like the path answers. I use choco package manager for node.js. Gulp would not fire for me unless it was:

  1. Globally installed npm i -g gulp and local dir npm i --save-dev gulp

  2. The problem persisted beyond this once, which was fixed by completely removing node.js and reinstalling it.

I didn't see any comments about local/global and node.js removal/reinstall.

3

This is most commonly because it is not found on environment variables as others have pointed out. This is what worked for me.

echo %PATH%

This will show you what's one your PATH environment variable. If node_modules is not there there do the following to add it from your APPDATA path.

PATH = %PATH%; %APPDATA%\npm

Illuminati
  • 4,251
  • 1
  • 32
  • 53
  • That's the only correct answer here. Either set a NODE_PATH variable AND add it to the PATH variable or directly add the global npm folder to your PATH variable. – DevAntoine Sep 01 '15 at 16:02
3

I resolved it by adding C:\Users\[USER]\AppData\Roaming\npm to PATH and not C:\Users\[USER]\AppData\Roaming\npm\node_modules

Marcos Cassiano
  • 737
  • 7
  • 12
  • 1
    This solution was already posted in [December 2014](http://stackoverflow.com/a/27295145/1906307). – Louis Oct 08 '15 at 16:28
3

I already had the one condition from this answer (I don't know why)

https://stackoverflow.com/a/27295145/1175496

That is, my PATH already included %APPDATA%\npm

In my case, the problem was npm was not installing modules there (again, I don't know why)

Therefore I needed to do this:

$ npm config set prefix -g %APPDATA%/npm

After that, running $ npm install -g gulp (or installing any other module) put the module in the place where PATH expects it.

Community
  • 1
  • 1
The Red Pea
  • 12,346
  • 12
  • 77
  • 112
3

This works for me:

 npm link gulp
 npm update
Werner Kvalem Vesterås
  • 9,400
  • 5
  • 37
  • 45
vineet
  • 10,659
  • 9
  • 50
  • 69
3

On my Windows 10 Enterprise, gulp was not installed in %AppData%, which is C:\Users\username\AppData\npm\node_modules on my machine, but in C:\Users\username\AppData\Local\npm\node_modules.

To get gulp to be picked up at the command prompt or in powershell, I added to the user PATH the value C:\Users\username\AppData\Local\npm. After that it worked like a charm. Naturally I had to close the command prompt or powershell window and re-open for the above to take effect.

2

Had gulp command not found problem in windows 10 and Adding "%AppData%\npm\node_modules" doesn't work for me. Do this steps please:

After doing

npm install -g npm

And

npm install -g gulp

Add

C:\Users\YourUsername\npm

to Path in System Variables.

It Works for me after all solutions failed me.

A. Najafi
  • 83
  • 1
  • 1
  • 4
2

Run npm install gulp -g

if you are using windows, please add the gulp's dir to PATH.

such like C:\Users\YOURNAME\AppData\Roaming\npm\node_modules\gulp

Louis Barranqueiro
  • 8,594
  • 5
  • 35
  • 49
2

In windows:

  1. Using your windows explorer, Navigate to your vagrant shared folder (I am using scotchbox by the way) e.g C:\scotchbox/public/gulpProject
  2. In the address bar of the folder, type cmd and press Enter
  3. Do your gulp installation npm install
Tunaki
  • 116,530
  • 39
  • 281
  • 370
Justis Matotoka
  • 789
  • 5
  • 3
2

In short:

You should add %NODE_PATH% to the system variable Path if the other answers don't work.

The reason:

The point is, command prompt only executes programs under the Path system variable, not the user variables. If you have NODE_PATH set as a user variable, add %NODE_PATH% to Path.


I asked here and got marked duplicate for a question with different intention :(

NPM Windows doesn't execute program under the User Variable path [duplicate]

Community
  • 1
  • 1
Daniel Cheung
  • 4,258
  • 1
  • 25
  • 54
2

In Windows:

  1. Press the following two keys: Windows + r
  2. Type control /name microsoft.system into the run dialog box that appears from the previous step.

Windows run dialog box

  1. Select Advanced System Settings from the left of the window pane
  2. Click the Advanced tab on the system properties box that appears and click the Environment Variables button.
  3. Edit the PATH User environment variable.
  4. Click New on the edit environment variable window that pops up for the PATH variable and add the following: %APPDATA%\npm to the start of the PATH environment variable (as shown in the image below).

Setting the environmental variable

  1. Close your Command Prompt and reopen it.
JSON C11
  • 8,722
  • 5
  • 69
  • 61
1

Navigate to where you installed node modules in cmd up to .bin folder, then run gulp. I.e. path\node_modules.bin>>gulp
This worked for me excellently. My path was C:\wamp\www\wyntonv2\node_modules.bin

JOHN MAINA
  • 23
  • 7
1

If you need to install a global version gulp as described on the gulpjs.com site and still have issues, you may need to clean npm's cache. For instance, if you have previously installed gulp and managed to blow it away by accident, it may not install properly again because it's looking for directories that no longer exist. In which case, run:

sudo npm cache clean

Then install gulp as you normally would.

headwinds
  • 1,642
  • 15
  • 22
1

In my case, none of the approaches listed worked. I finally downloaded Rapid Environment Editor (ver 8).

It showed that my additions to the user environment variables weren't present. When I added them with REE, everything worked immediately.

(Running Windows 8.1)

john elemans
  • 2,385
  • 2
  • 13
  • 26
1

I have come across this issue. I fixed this by adding %APPDATA%/npm to Path Environment variable. I didn't define NODE_PATH variable still it worked for me. Hope this works for others!!

0
  1. When you've installed gulp global, you need to go to

    C:\nodejs\node_modules\npm\npm

  2. There you do

    SHIFT + Right Click

  3. Choose "Open command prompt here"

  4. Run gulp from that cmd window

Kolky
  • 2,869
  • 1
  • 19
  • 42
0

Nothing Worked for me except

Run powershell as administrator and executing Set-ExecutionPolicy RemoteSigned.

For More Detail : PowerShell says "execution of scripts is disabled on this system."

coder618
  • 551
  • 1
  • 4
  • 8
0

Run Power-shell as administrator.

then run this command

Set-ExecutionPolicy Unrestricted

Use with CAUTION

coder618
  • 551
  • 1
  • 4
  • 8
-1

So I haven't seen this answer yet, and that NODE_PATH and all these other so-called environment variable fixes didn't do anything, so I thought I'd add my brute force way of getting this to work:

Obviously you install the latest node.js and do npm install. I also had to upgrade some dependencies first (was getting warnings on these when I tried to install gulp, and before I ran these commands it was telling me it was missing the popper.js dependency Bootstrap 4 required - even though it was actually ok in that department!):

npm install -g minimatch (Enter)

npm install -g graceful-fs (Enter)

I saw when I did npm install -g gulp, again, though (and it was failing to run), it was putting it in C:\Users\myname\AppData\Roaming\npm\node_modules

So because I was running gulp from a command line that was cd'd to my project folder in: C:\Users\myname\Documents\Visual Studio 2015\Projects\myproject

I doubt it knew anything about that other location. Also my package.json didn't have:

"scripts":{
    "gulp": "gulp"
 }

Instead, it had:

"scripts":{
    "start": "gulp"
 }

So it could not run gulp, anyway, even if it had been installed to the project. I guess at this point maybe if I had ran start instead of gulp, it might've worked, but so I added a comma after "gulp" and another line:

"scripts":{
    "start": "gulp",
    "gulp": "gulp"
 }

Then I copied the gulp folder from C:\Users\myname\AppData\Roaming\npm\node_modules\gulp to C:\Users\myname\Documents\Visual Studio 2015\Projects\myproject\node_modules\gulp

and it worked fine after that.

vapcguy
  • 5,607
  • 1
  • 45
  • 43
-1

None of the given answers didn't worked for me. Because my issue was the gulp commands are blocked by Antivirus. I had installed the Gulp both globally and locally successfully. Mine is Kaspersky antivirus and once i allowed gulp in the antivirus firewall it works like a charm.

CodeCanyon
  • 855
  • 1
  • 11
  • 30
-1
  1. npm install -g gulp
  2. Add environment variables in windows: enter image description here
Agnel Amodia
  • 667
  • 7
  • 18