pedalpete
pedalpete

Reputation: 21536

gulp command not found - error after installing gulp

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 [email protected] with the location of either my global or local gulp installation.

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

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

Upvotes: 258

Views: 391269

Answers (30)

Gaurav Goel
Gaurav Goel

Reputation: 601

  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.

Upvotes: 50

serge
serge

Reputation: 15219

Another cause for the problem in Windows is the environment variable:

NODE_ENV                       production

With this having set, all devDependencies along with the gulp folder will be removed after the npm install, so it will never find the local gulp.

Upvotes: 0

yeralin
yeralin

Reputation: 1407

One right way:

  1. Win + R : type "%appdata%"
  2. Go to npm folder
  3. Copy whole path like "C:\Users\...\npm"
  4. Go to "My Computer" + Right Click "Properties"
  5. Open "Advanced System Settings" (On the left)
  6. Click on "Environment Variables"
  7. Click on "Edit Path"
  8. Add that "C:\Users\...\npm" to the end and type ";" after that
  9. Click ok, reopen cmd and try npm command again

Upvotes: 17

Speeday
Speeday

Reputation: 73

Above solution are awesome, but here I want to share an solution for Existing Project in which this issue got reported many times due to which we use to reinstall Gulp and all.

Environment for Issue:-

  • Current OS:- Windows 10 x64 bit.
  • Working with Gulp Project with previous version of Node v10.24.0 and now not working with Node v14.15.0.

Solution:-

  • First Option:- Changed in Node Version of the Project Directory from v14.15.0 to v10.24.0 and than Gulp Command runs fine.

  • Second Option:-. Reinstall all the Packages and Gulp with Current Version of Node v14.15.0.

Hope this would be helpful to anyone.

Upvotes: 0

coder618
coder618

Reputation: 1004

Run Power-shell as administrator.

then run this command

Set-ExecutionPolicy Unrestricted

Use with CAUTION

Upvotes: 0

coder618
coder618

Reputation: 1004

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."

Upvotes: 0

praveen poonja
praveen poonja

Reputation: 19

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!!

Upvotes: 1

Skylin R
Skylin R

Reputation: 2271

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

Upvotes: 14

user9844377
user9844377

Reputation:

(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.

Upvotes: 4

David Scarfo
David Scarfo

Reputation: 31

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.

Upvotes: 3

Agnel Amodia
Agnel Amodia

Reputation: 769

  1. npm install -g gulp
  2. Add environment variables in windows: enter image description here

Upvotes: -1

The Odd Developer
The Odd Developer

Reputation: 929

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.

Upvotes: -1

vapcguy
vapcguy

Reputation: 7537

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.

Upvotes: -1

miojamo
miojamo

Reputation: 747

The simple solution just do npm link gulp

Upvotes: 21

Habib Adıbelli
Habib Adıbelli

Reputation: 1181

  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.

Upvotes: 92

SteveLacy
SteveLacy

Reputation: 4166

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.

Upvotes: 231

Badr Bellaj
Badr Bellaj

Reputation: 12821

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

Upvotes: 15

Kranti123
Kranti123

Reputation: 199

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

Upvotes: 4

christo8989
christo8989

Reputation: 6826

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.

Upvotes: 7

JSON C11
JSON C11

Reputation: 11792

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.

Upvotes: 2

Amit Sharma
Amit Sharma

Reputation: 163

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

Screen capture:

cmd

Upvotes: 4

ThinkBonobo
ThinkBonobo

Reputation: 16495

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

Upvotes: 9

user5700262
user5700262

Reputation:

  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

Upvotes: 0

csnate
csnate

Reputation: 2889

You forgot to install the gulp-cli package:

npm install -g gulp-cli

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

Upvotes: 275

Daniel Cheung
Daniel Cheung

Reputation: 4819

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]

Upvotes: 2

john elemans
john elemans

Reputation: 2666

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)

Upvotes: 1

vineet
vineet

Reputation: 14236

This works for me:

 npm link gulp
 npm update

Upvotes: 4

Justis Matotoka
Justis Matotoka

Reputation: 829

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

Upvotes: 3

Nate Anderson
Nate Anderson

Reputation: 21034

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.

Upvotes: 3

user5523785
user5523785

Reputation: 21

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

Upvotes: 2

Related Questions