Grunt on Windows 8: "grunt" is not recognized

I had a problem running grunt from the command line on my windows 8 machine.

My research shows that the most common solution is to install grunt-cli, since Grunt is no longer global. I also need to make sure that I really install the Grunt task runner, since this is not installed with grunt-cli.

Other solutions point to the PATH system environment variable, but it seems to be pointed out as I would expect:

C: \ Users [username] \ AppData \ Roaming \ NPM

Having done all this, I still get a "grunt" that is not recognized as an error message of an internal or external command, operating program, or batch file in the CLI. I tried the following things, removing everything after each attempt:

  • Installed grunt-cli globally (npm install -g grunt-cli), then grunt at the directory level I want to use (npm install grunt)
  • Same as above, but with a change in installation order
  • Same as above, but using Admin command line

Am I missing something obvious?

+56
gruntjs grunt-cli
Oct 02 '13 at 11:09
source share
11 answers

Confirm that your PATH correct (and not corrupted). Just enter PATH from the command line. There is no other explanation that makes sense given the error you described and the steps you took.

Normally, using the where grunt command, you would find grunt.cmd in your path if npm installed correctly and it was correctly added to the system path.

+33
Oct 02 '13 at
source share

I had no problems grunting on multiple Windows 8 machines.

If you open the folder: C:\Users\[username]\AppData\Roaming\npm

Do you have a file called grunt.cmd in this folder?

If not, I would try npm install -g grunt-cli again, possibly from an elevated command prompt.

If this exists, and you have C:\Users\[username]\AppData\Roaming\npm in your PATH environment variable, then use the grunt command from the command line.

Stupid question: did you try to close the command line and open a new one?

+60
02 Oct '13 at 11:50 on
source share
  • Close all command line instances.
  • Launch a new instance of the command line.
  • Type PATH Enter and check if C:\Users\Username\AppData\Roaming\npm part of the path.
  • If not, you need to log out again and again ,
    or close the command line and restart the explorer process.
  • At the command prompt, enter where grunt Enter .
    You are good if he reports:

     C:\Users\Username\AppData\Roaming\npm\grunt C:\Users\Username\AppData\Roaming\npm\grunt.cmd 
  • Otherwise, you need to reinstall the grunt-cli package if it reports:

     INFO: Could not find files for the given pattern(s). 

Apparently, programs that change the PATH environment variable should pass the WM_SETTINGCHANGE message. The Windows System Preferences window does this correctly when changing the PATH variable, but the NPM installer does not. Therefore, you need to restart the explorer (either log out or restart, which has the same effect).

+15
Feb 17 '14 at 18:51
source share

I had the same problem.

I tried different things:

  • Reboot the computer.
  • Grunt folder removed and running

npm install -g grunt -cli

Does not work.

Finally tried:

npm install -g grunt-cli

Worked great.

I tried

where grunt

and I saw 2 locations where it was found.

+5
May 29 '14 at 18:02
source share

I know this is the answer, but I thought I was offering my step-by-step solution for Windows 8.

The first thing I checked was PATH on my laptops. Environment variables (right click on my computer> properties> advanced system settings> environment variables)

It was not listed there, so I added a new variable to the user variables (so it was specific to my user account only)

In a new user variable prompt, I entered the following:

 Variable Name: PATH Variable Value: %USERPROFILE%\AppData\Roaming\npm 

Close the command line, drag it, go to my projects directory and try running grunt again and ... SUCCESS!

+4
Jun 17 '14 at
source share

I encountered the same problem on windows 8

I added '% APPDATA% \ npm' to the path variable. It works great.

+3
Aug 18 '15 at 4:34
source share

several times the NPM installation distorts the main path to the window. I usually have a copy of my own version of PATH separately. every week, or on some installations, I manually configure and update the% PATH% variable.

Basically, Grunt.cmd does not have access to the% PATH% variable.

+1
Nov 06 '13 at 16:03
source share

I ran into a problem in Windows 8, after installing grunt-cli, I always had a β€œnot found” command while trying to check grunt -v or where grunt . Therefore, I added this path C:\Program Files (x86)\Git\local to the PATH environment and ran grunt.cmd from this folder (you need to look here in the node_modules folder). And after rebooting my terminal everything started working.

+1
Oct 22 '14 at 20:49
source share

The same thing happened to me, and here is the solution: Do you have two different versions of Node.JS? Maybe Nodist? This means that you probably installed NPM twice, which installs the commands in two different folders: Once in C:\Users\<user>\AppData\Roaming\npm and once in C:\dev\nodist\bin\bin .

C:\dev\nodist\bin\bin not in my variable path, so I added it and I deleted the version of Node.JS that I did not want to use.

+1
Mar 18 '15 at 11:16
source share

If you do not have the grunt.cmd file created by npm, make sure you do not have .npmrc in your home directory with: bin-links=false in it.

0
May 16 '15 at 20:56
source share

Just run:

 npm install -g grunt-cli 
-one
Nov 07 '14 at 15:13
source share



All Articles