简体   繁体   English

如何在Windows上的webstorm中设置grunt

[英]how to setup grunt in webstorm on windows

I am Using Webstorm (PHPStorm) on Windows 7 . 我在Windows 7上使用Webstorm(PHPStorm) On the actual project we are using grunt to concatenate javascript and css and also for several other build processes. 在实际项目中,我们使用grunt来连接javascript和css以及其他几个构建过程。

I tried to setup the grunt command as an external run command in Webstorm. 我试图在Webstorm中将grunt命令设置为外部运行命令。 The settings i tried for that are: 我试过的设置是:

Name: grunt  
Parameters: none  
WorkingDirectory: $ProjectFileDir$

So now when I am trying to start my external run command in Webstorm, I always get the error 所以现在当我试图在Webstorm中启动我的外部运行命令时,我总是得到错误

> grunt
Cannot run program "grunt" (in directory "C:\Users\jawidmer\workspaces\projectname"): CreateProcess error=2, The system cannot find the file specified

When I open my command line tool and navigate to the project folder, I can start grunt without any problems. 当我打开命令行工具并导航到项目文件夹时,我可以毫无问题地开始咕噜声。

I already searched in google and tried all kinds of different combinations of settings but non of them worked.. 我已经在谷歌搜索并尝试了各种不同的设置组合,但没有他们工作..

Do you have any ideas, what I have to change to be able to start grunt from external run commands in Webstorm? 你有什么想法,我必须改变什么才能从Webstorm中的外部运行命令开始咕噜咕噜?

Thanks Jan 谢谢Jan

By your description, I assume that the same way I configured it in my WebStorm installation should work just fine for you too: 根据您的描述,我假设我在WebStorm安装中配置它的方式也应该适合您:

Grunt WebStorm配置

I hope it helps. 我希望它有所帮助。


UPDATE UPDATE

It seems that if you add > %TEMP%\\grunt & type %TEMP%\\grunt & del %TEMP%\\grunt to Parameters (like shown in the updated image), the build errors will be shown. 似乎如果向参数添加> %TEMP%\\grunt & type %TEMP%\\grunt & del %TEMP%\\grunt (如更新的图像中所示),将显示构建错误。

If you need to configure a task (for example grunt watch ), the Parameters field must be the following: 如果需要配置任务(例如grunt watch ),则Parameters字段必须如下:

watch > %TEMP%\grunt & type %TEMP%\grunt & del %TEMP%\grunt

Tip taken from here 提示取自这里

Maybe this variant will be useful for somebody: Settings -> External Tools 也许这个变体对某些人有用:设置 - >外部工具

在此输入图像描述

With this tool I can right-click folder in project and in context menu select grunt -> build 使用此工具,我可以右键单击项目中的文件夹,然后在上下文菜单中选择grunt - > build

As I had problems with the path of node and grunt in linux. 因为我在linux中遇到了node和grunt的路径问题。 I've decide to add the following in Settings->External Tools, I guess in windows can be done in the same way (PHPstorm 7, in the same dialog as the prior answers): 我决定在Settings-> External Tools中添加以下内容,我猜在windows中可以用同样的方式完成(PHPstorm 7,在与之前答案相同的对话框中):

Name: grunt Group: Node 名称:grunt组:节点

Program: /opt/nodes/current/bin/node (my path to node files) Parameters: /my/directory/node_modules/grunt-cli/bin/grunt watch (my path to grunt-cli binary and the parameter to the task of grunt) Working directory: /home/user/project/ (my path to Gruntfile.js) 程序: /opt/nodes/current/bin/node (我的节点文件路径)参数: /my/directory/node_modules/grunt-cli/bin/grunt watch (我的grunt-cli二进制路径和任务的参数) of grunt)工作目录: /home/user/project/ (我的Gruntfile.js路径)

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

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