简体   繁体   English

在Windows上运行Grunt时出错:致命错误:无法找到本地Grunt

[英]Error running Grunt on Windows : Fatal error: Unable to find local grunt

I know there are lots of questions about this problem, but mine is a bit different. 我知道关于这个问题有很多疑问,但是我的有点不同。

I have nodejs installed on Windows , at c:\\program files\\nodejs 我在Windows上安装了nodejs,位于c:\\ program files \\ nodejs

I installed all desired modules in the folder above, using these commands : 我使用以下命令在上述文件夹中安装了所有需要的模块:

npm install grunt --save-dev
npm install grunt-contrib-uglify --save-dev
npm install grunt-contrib-cssmin
npm install grunt-contrib-imagemin --save-dev

If i go inside my app folder and try to execute grunt, i get this error : 如果我进入我的应用程序文件夹并尝试执行grunt,我会收到此错误:

Fatal error: Unable to find local grunt 致命错误:无法找到本地咕unt声

Grunt will run only if i reinstall all modules INSIDE the folder of my app. 仅当我重新安装应用程序文件夹中的所有模块时,Grunt才会运行。

My question is : i have to install the modules inside EVERY app folder ? 我的问题是:我必须在每个应用程序文件夹中安装模块吗? The same modules already installed on nodejs folder arent'enough ? 已经在nodejs文件夹中安装了相同的模块?

Thanks ! 谢谢 !

Yes, the modules should be installed inside project directory. 是的,这些模块应该安装在项目目录中。 If you want to install node module globally, you should use --global flag, eg npm install --global grunt . 如果要全局安装节点模块,则应使用--global标志,例如npm install --global grunt But installing grunt and grunt modules globally isn't good idea because of dependency management. 但是由于依赖管理,在全球范围内安装grunt和grunt模块不是一个好主意。 You may get into trouble when update grunt or grunt modules installed globally. 更新全局安装的grunt或grunt模块时,您可能会遇到麻烦。

Read grunt Getting Started for more information. 阅读grunt 入门获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM