“grunt”对于某些windows用户来说不被认为是一个内部或外部命令

时间:2022-03-02 08:11:32

Grunt is not working for all Windows users. Some users are facing some issues, when I run npm install command; it prints a message as below.

Grunt不适用于所有Windows用户。有些用户在运行npm安装命令时遇到了一些问题;它打印如下所示的消息。

E:\Worksapce\web>npm install
npm WARN package.json registers@4.0.0 No repository field.

When I tried npm install -g grunt-cli, I think it is successful.

当我尝试npm安装-g grunt-cli时,我认为它是成功的。

E:\Worksapce\web>npm install -g grunt-cli
npm http GET http://registry.npmjs.org/grunt-cli
npm http 304 http://registry.npmjs.org/grunt-cli
npm http GET http://registry.npmjs.org/nopt
npm http GET http://registry.npmjs.org/findup-sync
npm http GET http://registry.npmjs.org/resolve
npm http 304 http://registry.npmjs.org/nopt
npm http 304 http://registry.npmjs.org/resolve
npm http 304 http://registry.npmjs.org/findup-sync
npm http GET http://registry.npmjs.org/abbrev
npm http 304 http://registry.npmjs.org/abbrev
npm http GET http://registry.npmjs.org/glob
npm http GET http://registry.npmjs.org/lodash
npm http 304 http://registry.npmjs.org/glob
npm http 304 http://registry.npmjs.org/lodash
npm http GET http://registry.npmjs.org/inherits
npm http GET http://registry.npmjs.org/minimatch
npm http 304 http://registry.npmjs.org/minimatch
npm http 304 http://registry.npmjs.org/inherits
npm http GET http://registry.npmjs.org/lru-cache
npm http GET http://registry.npmjs.org/sigmund
npm http 304 http://registry.npmjs.org/lru-cache
npm http 304 http://registry.npmjs.org/sigmund
C:\Users\user1234\AppData\Roaming\npm\grunt -> C:\Users\user1234\AppData\Roaming
\npm\node_modules\grunt-cli\bin\grunt
grunt-cli@0.1.13 C:\Users\user1234\AppData\Roaming\npm\node_modules\grunt-cli
+-- resolve@0.3.1
+-- nopt@1.0.10 (abbrev@1.0.5)
+-- findup-sync@0.1.3 (lodash@2.4.1, glob@3.2.11)

But when I run grunt, I get an error message like this:

但是当我运行grunt时,我得到一个这样的错误信息:

E:\Worksapce\web>
E:\Worksapce\web>grunt
'grunt' is not recognized as an internal or external command,
operable program or batch file.

My package.json is this.

我的包。json是这样的。

{
  "author": "Company",
  "name": "registers",
  "version": "4.0.0",
  "homepage": "http://abcd.se",
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.4",
    "grunt-contrib-jshint": "~0.9.2",
    "grunt-contrib-watch": "~0.6.1",
    "grunt-contrib-less": "~0.11.0",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-contrib-copy": "~0.5.0",
    "grunt-contrib-concat": "~0.3.0",
    "grunt-contrib-uglify": "~0.4.0",
    "grunt-ngmin": "0.0.3",
    "grunt-contrib-jasmine": "~0.5.2"
  }
}

Another user is succesfully able to execute grunt with out any issues. This only stands for some of the users.

另一个用户可以在任何问题上执行grunt。这只代表一些用户。

Can some one tell me what has gone wrong.

有人能告诉我出了什么事吗?

6 个解决方案

#1


48  

Grunt is no longer installed globally. See the Getting Started page for more information.

Grunt不再在全球安装。有关更多信息,请参见入门页面。

The command below should help you fix this;

下面的命令应该可以帮助您修复这个问题;

npm install -g grunt-cli

#2


14  

Your logs indicate that the grunt command was created in your global directory. The errors also indicate that C:\Users\mc862634\AppData\Roaming\npm\ is not in your path.

日志表明grunt命令是在全局目录中创建的。错误也表明C:\Users\mc862634\AppData\Roaming\npm\不在你的路。

You'll want to check your PATH and make sure that the \AppData\Roaming\npm location is added if it is missing.

您将需要检查您的路径,并确保在丢失时添加了\AppData\漫游\npm位置。

The easiest way to check is to open a command prompt and type PATH.

检查的最简单方法是打开命令提示符并输入路径。

See this other * question as a reference: Grunt on Windows 8: 'grunt' is not recognized

另一个*问题作为参考:在Windows 8上咕哝:“咕哝”不被识别

#3


11  

On Windows 8, Grunt needs to have the following added to the PATH:

在Windows 8上,Grunt需要在路径中添加以下内容:

C:\Users\your_username\AppData\Roaming\npm

On some systems, the number of characters allowable in the PATH is limited, and this can cause the correct path needed by grunt to not be added, even after npm install -g grunt-cli is run. Some settings (for example for certain programs you have installed) can be safely removed from the PATH, as they're generally there as a failsafe and often aren't required. If you have this issue:

在某些系统中,路径中允许的字符数是有限的,这可能导致grunt所需要的正确路径不被添加,即使是在运行npm安装-g grunt-cli之后。有些设置(例如您已经安装的某些程序)可以安全地从路径中删除,因为它们通常作为故障保护而存在,并且通常不需要这些设置。如果你有这个问题:

  • Backup the variables in your PATH (This PC > right-click > Properties > Advanced system settings > Environment Variables > 'Edit' the 'Path' user variables for the current user, and copy the 'Variable value' and save it somewhere)
  • 备份您路径中的变量(此PC >右击>属性>高级系统设置>环境变量>“编辑”当前用户的“路径”用户变量,并复制“变量值”并将其保存到某个地方)
  • Remove some of the values from the PATH, and add in the path C:\Users\your_username\AppData\Roaming\npm
  • 删除一些值的路径,并添加路径中C:\Users\ your_username \ AppData \ \ npm徘徊

Also, make sure that after installing the Grunt CLI and adding the path, that you close any open command windows and re-open them before trying a Grunt

另外,请确保在安装了Grunt CLI并添加路径之后,关闭任何打开的命令窗口并在尝试一个Grunt之前重新打开它们。

#4


2  

Grunt-CLI is installed inside %AppData%\npm, so the best directory to add to your %PATH% is:

Grunt-CLI安装在%AppData%\npm中,因此向%PATH%添加的最佳目录是:

%AppData%\npm

#5


1  

Incase that there some developer that used Windows XP, that have similar problem you'll need to change Path entry.

如果有使用Windows XP的开发人员遇到类似的问题,您需要更改路径条目。

From: C:\Users\change_username\AppData\Roaming\npm\grunt

来自:C:\Users\ change_username \ AppData \漫游\ npm \咕哝

To: C:\Documents and Settings\change_username\Application Data\npm

:C:\Documents and Settings\ change_username \ \ npm的应用程序数据

#6


0  

npm install grunt -g (or) npm install -g grunt-cli Please check your computer environmental variable path, it should contain the path of AppData. EX: E:\$APPDATA\npm\;

npm安装grunt -g(或)npm安装-g grunt-cli请检查您的计算机环境变量路径,它应该包含AppData的路径。例:E:\ $ APPDATA \ npm \;

MyComputer->Right click-> Properties ->Advances System Setting-> Environment Variables -> Path

MyComputer->右击>属性->推进系统设置->环境变量->路径。

#1


48  

Grunt is no longer installed globally. See the Getting Started page for more information.

Grunt不再在全球安装。有关更多信息,请参见入门页面。

The command below should help you fix this;

下面的命令应该可以帮助您修复这个问题;

npm install -g grunt-cli

#2


14  

Your logs indicate that the grunt command was created in your global directory. The errors also indicate that C:\Users\mc862634\AppData\Roaming\npm\ is not in your path.

日志表明grunt命令是在全局目录中创建的。错误也表明C:\Users\mc862634\AppData\Roaming\npm\不在你的路。

You'll want to check your PATH and make sure that the \AppData\Roaming\npm location is added if it is missing.

您将需要检查您的路径,并确保在丢失时添加了\AppData\漫游\npm位置。

The easiest way to check is to open a command prompt and type PATH.

检查的最简单方法是打开命令提示符并输入路径。

See this other * question as a reference: Grunt on Windows 8: 'grunt' is not recognized

另一个*问题作为参考:在Windows 8上咕哝:“咕哝”不被识别

#3


11  

On Windows 8, Grunt needs to have the following added to the PATH:

在Windows 8上,Grunt需要在路径中添加以下内容:

C:\Users\your_username\AppData\Roaming\npm

On some systems, the number of characters allowable in the PATH is limited, and this can cause the correct path needed by grunt to not be added, even after npm install -g grunt-cli is run. Some settings (for example for certain programs you have installed) can be safely removed from the PATH, as they're generally there as a failsafe and often aren't required. If you have this issue:

在某些系统中,路径中允许的字符数是有限的,这可能导致grunt所需要的正确路径不被添加,即使是在运行npm安装-g grunt-cli之后。有些设置(例如您已经安装的某些程序)可以安全地从路径中删除,因为它们通常作为故障保护而存在,并且通常不需要这些设置。如果你有这个问题:

  • Backup the variables in your PATH (This PC > right-click > Properties > Advanced system settings > Environment Variables > 'Edit' the 'Path' user variables for the current user, and copy the 'Variable value' and save it somewhere)
  • 备份您路径中的变量(此PC >右击>属性>高级系统设置>环境变量>“编辑”当前用户的“路径”用户变量,并复制“变量值”并将其保存到某个地方)
  • Remove some of the values from the PATH, and add in the path C:\Users\your_username\AppData\Roaming\npm
  • 删除一些值的路径,并添加路径中C:\Users\ your_username \ AppData \ \ npm徘徊

Also, make sure that after installing the Grunt CLI and adding the path, that you close any open command windows and re-open them before trying a Grunt

另外,请确保在安装了Grunt CLI并添加路径之后,关闭任何打开的命令窗口并在尝试一个Grunt之前重新打开它们。

#4


2  

Grunt-CLI is installed inside %AppData%\npm, so the best directory to add to your %PATH% is:

Grunt-CLI安装在%AppData%\npm中,因此向%PATH%添加的最佳目录是:

%AppData%\npm

#5


1  

Incase that there some developer that used Windows XP, that have similar problem you'll need to change Path entry.

如果有使用Windows XP的开发人员遇到类似的问题,您需要更改路径条目。

From: C:\Users\change_username\AppData\Roaming\npm\grunt

来自:C:\Users\ change_username \ AppData \漫游\ npm \咕哝

To: C:\Documents and Settings\change_username\Application Data\npm

:C:\Documents and Settings\ change_username \ \ npm的应用程序数据

#6


0  

npm install grunt -g (or) npm install -g grunt-cli Please check your computer environmental variable path, it should contain the path of AppData. EX: E:\$APPDATA\npm\;

npm安装grunt -g(或)npm安装-g grunt-cli请检查您的计算机环境变量路径,它应该包含AppData的路径。例:E:\ $ APPDATA \ npm \;

MyComputer->Right click-> Properties ->Advances System Setting-> Environment Variables -> Path

MyComputer->右击>属性->推进系统设置->环境变量->路径。