[英]Grunt.js Installation Issue - Command Not Found
I'm trying to get grunt.js
set up on my work machine. 我正在尝试在工作机器上设置
grunt.js
。 Now I've managed to get it set up at home, so I pushed my repository, then cloned it on my work machine, however despite troubleshooting this to death I've always run into the same issue when I come to try and run the command on my work computer; 现在,我已经设法在家里进行设置,因此我推送了存储库,然后将其克隆到了工作计算机上,但是尽管进行了故障排除,但是当我尝试运行存储库时,我总是遇到相同的问题在我的工作计算机上执行命令;
sh.exe": grunt: command not found
So some background and explanation; 因此有一些背景和解释;
Aptana 3.0
and running all my commands through the terminal. Aptana 3.0
并通过终端运行所有命令。 (This applies to my home and work computer) package.json
and gruntfile.js
files inside said directory. package.json
和gruntfile.js
文件放在上述目录中。 These work fine on my home computer and I am able to run the watch task set up in my gruntfile.js
successfully at home. gruntfile.js
成功运行在gruntfile.js
设置的监视任务。 npm install grunt-cli -g
and npm install
inside my project on my WORK computer and installation has been successful each time. npm install grunt-cli -g
和npm install
并且每次安装都成功。 My only error messages on either are a lack of description and a repository field which, to my knowledge these aren't mandatory? The node modules folder inside my repository indicates I have the following installed (as per my package.json) 我的存储库中的node modules文件夹指示我已经安装了以下文件(根据我的package.json)
grunt
grunt-contrib-compass
grunt-contrib-uglify
grunt-contrib-watch
matchdep
Now I'm pretty green to this command line stuff, so I may have overlooked something very obvious but I feel like I've tried every guide going to get this thing to work. 现在,我对这行命令行非常满意,因此我可能忽略了一些非常明显的内容,但是我觉得自己已经尝试了所有指南来使该功能正常工作。
Despite running through the getting started steps/installing grunt documentation repeatedly, it seems no matter what I do the terminal will not pick up grunt as a recognized command. 尽管反复执行了入门步骤/反复安装了grunt文档,但无论我做什么,终端都不会选择grunt作为公认的命令。
Am I stupid or is this some other issue? 我是愚蠢的还是其他问题?
EDIT 1: contents of my package.json: 编辑1:我的package.json的内容:
{ "name" : "xxxxxxxxx", "version" : "xxxx", "dependencies" : { "grunt":"~0.4.1", "grunt-contrib-watch": "~0.5.3", "grunt-contrib-compass": "~0.5.0", "grunt-contrib-uglify": "~0.2.2", "matchdep": "~0.1.2" } }
Try to run 尝试跑步
npm install grunt-cli -g
On your home computer. 在您的家用计算机上。
-g
means - install Grunt globally (not in the project node_modules folder), so it'll add grunt command to the bin folder which is used by nodejs console ( and you need to run node.js command prompt, not just arbitrary cmd) -g
表示-全局安装Grunt(不在项目node_modules文件夹中),因此它将grunt命令添加到nodejs控制台使用的bin文件夹中(并且您需要运行node.js命令提示符,而不仅仅是运行cmd)
This is happening because you are using the Aptana Terminal, which needs the PATH variable to work out what is meant by grunt etc. A normal cmd prompt would work fine with the command npm install grunt-cli -g
but in this context the terminal is unaware of what grunt
is. 发生这种情况的原因是您使用的是Aptana Terminal,它需要使用PATH变量来确定grunt等的含义。正常的cmd提示符对于命令
npm install grunt-cli -g
可以正常使用,但是在这种情况下,该终端是不知道什么是grunt
。
As per the following existing answer, you need to set up your Windows PATH variable to make the Aptana Terminal aware of the npm directory: https://stackoverflow.com/a/19137584/463205 根据以下现有答案,您需要设置Windows PATH变量以使Aptana Terminal知道npm目录: https ://stackoverflow.com/a/19137584/463205
C:\\Users\\Username\\AppData\\Roaming\\npm
Closing the terminal and reopening it after setting the PATH correctly should enable you to run the command successfully. 正确设置PATH之后,关闭终端并重新打开它,将使您能够成功运行命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.