Grunt不适用于所有Windows用户。当我运行npm install
命令时,一些用户面临一些问题;它打印如下信息:
E:Worksapceweb>npm install
npm WARN package.json registers@4.0.0 No repository field.
当我尝试npm install -g grunt-cli
时,我认为它是成功的。
E:Worksapceweb>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:Usersuser1234AppDataRoamingnpmgrunt -> C:Usersuser1234AppDataRoaming
npmnode_modulesgrunt-clibingrunt
grunt-cli@0.1.13 C:Usersuser1234AppDataRoamingnpmnode_modulesgrunt-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)
但是当我运行grunt时,我得到这样的错误消息:
E:Worksapceweb>
E:Worksapceweb>grunt
'grunt' is not recognized as an internal or external command,
operable program or batch file.
我的包。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"
}
}
另一个用户能够成功执行grunt,没有任何问题。这只代表部分用户。
谁能告诉我出了什么事
Grunt不再被全局安装。有关更多信息,请参阅入门页。
下面的命令可以帮助你解决这个问题;
npm install -g grunt-cli
日志显示在全局目录下创建了grunt
命令。这些错误还表明C:Usersmc862634AppDataRoamingnpm
不在您的路径中。
你要检查你的PATH
,并确保AppDataRoamingnpm
的位置被添加,如果它是缺失的。
最简单的检查方法是打开命令提示符并输入PATH
。
查看这个其他StackOverflow问题作为参考:Grunt在Windows 8: ' Grunt '不被识别
在Windows 8上,Grunt需要在PATH
中添加以下内容:
C:Usersyour_usernameAppDataRoamingnpm
在某些系统上,PATH中允许的字符数是有限的,这可能导致没有添加grunt所需的正确路径,即使在运行npm install -g grunt-cli
之后也是如此。有些设置(例如您已经安装的某些程序)可以安全地从PATH中删除,因为它们通常是作为故障保险存在的,通常不是必需的。如果您有此问题:
- 备份
PATH
中的变量(本PC>右键单击>属性>高级系统设置>环境变量> '编辑'当前用户的'路径'用户变量,并复制'变量值'并将其保存在某处) - 从
PATH
中删除一些值,并添加路径C:Usersyour_usernameAppDataRoamingnpm
另外,请确保在安装Grunt CLI并添加路径后,在尝试Grunt
Grunt-CLI
安装在%AppData%npm中,所以添加到%PATH%
的最佳目录是:
%AppData%npm
npm install grunt -g(或)npm install -g grunt-cli请检查您的计算机环境变量路径,它应该包含AppData的路径。例:E: $ APPDATA npm ;
我的电脑->右键单击->属性->高级系统设置->环境变量->路径
如果有一些使用Windows XP的开发人员有类似的问题,您需要更改Path条目。
从>:C:Users change_username AppData 漫游 npm 繁重:C:Documents and Settings change_usernameApplication Datanpm