所以我搞砸了删除和安装节点和 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
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:
请注意,我有grunt-cli
安装。
你使用NVM来管理Node版本吗?该问题可能是由 NVM 用于修补环境变量的方式引起的。通常它把初始化逻辑放在 ~/.bashrc 中
如果从终端启动WebStorm,它将继承终端环境(包括修改PATH环境变量,添加NVM_DIR环境变量等)。在这种情况下,加载 Grunt 任务不会出现问题,因为 WebStorm 会看到正确的 PATH 值。
如果从桌面(而不是从终端)启动 WebStorm,WebStorm 会看到不正确的 PATH 值,并且无法加载 Grunt 任务。
如果您使用 bash 作为 shell,解决方法可能如下:编辑 WebStorm 启动器并将命令设置为“/bin/bash -l -c”/path/to/webstorm.sh”。此命令将执行 bash 登录(即读取您的 .bashrc/.bash_profile 文件),然后将运行 webstorm.sh。
希望这会有所帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)