Grunt on Windows 8: 'grunt' is not recognized

前端 未结 11 1986
刺人心
刺人心 2020-11-29 01:07

I\'m having a problem running Grunt from the command line on my Windows 8 machine.

My research indicates the most common solution is to install grunt-cli, since Gru

相关标签:
11条回答
  • 2020-11-29 01:37

    I've not had any issues with grunt on several different windows 8 machines.

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

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

    If not I'd maybe try npm install -g grunt-cli again, maybe from an elevated command prompt.

    If this exists and you have C:\Users\[username]\AppData\Roaming\npm in your PATH environment variable then typing grunt from a command prompt should work.

    Silly question, have you tried closing the command prompt and opening a new one?

    0 讨论(0)
  • 2020-11-29 01:38
    1. Close all Command Prompt instances.
    2. Start a new Command Prompt instance.
    3. Type PATH Enter and verify if C:\Users\Username\AppData\Roaming\npm is part of the path.
    4. If not, you need to log off and on again,
      or close the Command Prompt and restart the explorer process.
    5. In the Command Prompt, type where grunt Enter.
      You're good if it reports:

      C:\Users\Username\AppData\Roaming\npm\grunt
      C:\Users\Username\AppData\Roaming\npm\grunt.cmd
      
    6. Otherwise, you have 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 must broadcast a WM_SETTINGCHANGE message. The Windows' System settings window does it correctly when you change the PATH variable, but the NPM installer doesn't. That's why you have to restart explorer (or log off or restart, which has the same effect).

    0 讨论(0)
  • 2020-11-29 01:41

    I had the same issue.

    I tried different things:

    • Restart computer
    • Deleted the grunt folder and ran

    npm install -g grunt -cli

    Didn't work.

    Finally tried:

    npm install -g grunt-cli

    Worked perfectly.

    Tried

    where grunt

    and I saw 2 locations where it was found.

    0 讨论(0)
  • 2020-11-29 01:43

    After getting a tonne of "'grunt' is not recognized as an internal or external command," errors, I solved this on Windows 10 by going to Path and adding C:\Users\Username\AppData\Roaming\npm

    0 讨论(0)
  • 2020-11-29 01:46

    some times NPM install corrupts the basic windows path. i usually have a copy of my own version of PATH mainted separately. every week or on some installs i manually configure and update the %PATH% variable.

    Basically Grunt.cmd is not availbe through %PATH% variable.

    0 讨论(0)
提交回复
热议问题