Grunt on Windows 8: 'grunt' is not recognized

前端 未结 11 2032
刺人心
刺人心 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: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).

提交回复
热议问题