Webstorm不会识别Grunt [英] Webstorm does not recoginize Grunt

查看:299
本文介绍了Webstorm不会识别Grunt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我搞砸了删除和安装节点和npm来安装没有sudo的包,现在我不能在Webstorm中使用Grunt面板。

消息是:

  grunt --no-color --gruntfile /Users/max/repos/cb/Gruntfile.js --tasks / Applications /WebStorm.app/plugins/JavaScriptLanguage/grunt_js/tasks _intellij_grunt_tasks_fetcher 
不能运行程序grunt(在目录/ Users / max / repos / cb中):error = 2,没有这样的文件或目录

看起来grunt命令不在您的系统路径中。
为了查看/运行任务,您需要全局安装Grunt的命令行界面:

npm install -g grunt-cli

欲了解更多信息,请见http://gruntjs.com/getting-started

但是我可以运行grunt从终端,甚至在Webstorm。
截图:



请注意,我已经安装了 grunt-cli

解决方案

你使用NVM来管理Node版本吗?这个问题可能是由NVM用来修补环境变量的方式造成的。通常它将其初始化逻辑放在〜/ .bashrc中如果WebStorm从终端启动,它将继承终端环境(包括修改的PATH环境变量,添加NVM_DIR env var等) )。在这种情况下,加载Grunt任务没有问题,因为WebStorm可以看到正确的PATH值。



如果WebStorm是从桌面(而不是终端)启动的,WebStorm会认为不正确PATH值并且无法加载Grunt任务。



如果您使用bash作为shell,解决方法可能如下:编辑您的WebStorm启动器并将命令设置为/ bin / bash -l -c/path/to/webstorm.sh。该命令将执行bash登录(即读取.bashrc / .bash_profile文件),然后运行webstorm.sh。



希望有帮助。


So I have messed up with removing and installing node and npm to install packages without sudo and now I can't use Grunt panel in Webstorm

The message is:

grunt --no-color --gruntfile /Users/max/repos/cb/Gruntfile.js --tasks /Applications/WebStorm.app/plugins/JavaScriptLanguage/grunt_js/tasks _intellij_grunt_tasks_fetcher
Cannot run program "grunt" (in directory "/Users/max/repos/cb"): error=2, No such file or directory

Looks like the grunt command isn't in your system path.
In order to view/run tasks, you need to install Grunt's command line interface globally:

   npm install -g grunt-cli

For more information, please see http://gruntjs.com/getting-started

But what is strange than I can run grunt from terminal, even in Webstorm. Screenshot:

Notice that i have grunt-cli installed.

解决方案

Do you use NVM to manage Node versions? The problem might be caused by the way NVM uses to patch enviornment variables. Usually it places its initialization logic in ~/.bashrc

If WebStorm is launched from Terminal, it inherits Terminal environment (including modified PATH environment variable, added NVM_DIR env var, etc). In that case, there are no problems with loading Grunt tasks, as WebStorm sees correct PATH value.

If WebStorm is lauched from Desktop (not from Terminal), WebStorm sees incorrect PATH value and fails to load Grunt tasks.

If you're using bash as shell, workaround could be the the following: edit your WebStorm launcher and set command to "/bin/bash -l -c "/path/to/webstorm.sh". This command will perform bash login (i.e. reading your .bashrc/.bash_profile files) and after that will run webstorm.sh.

Hope that will help.

这篇关于Webstorm不会识别Grunt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆