Last Updated: February 25, 2016
·
14.02K
· eskimoblood

Run Grunt in WebStorm

As the Webstorm IDE has its own terminal you can run grunt from within your IDE. Unfortunately it isn't that easy when you work on a Mac. If you open the terminal in Webstorm and run grunt you will get an error that the program grunt couldn't be found. The reason is that GUI applications under MacOSX dont have the same environment variables as the terminal. This form post describe how to set your environmental variables. After following the description and rebooting your machine it will work as expected.

Now you can go to the preferences and search for external tools. Create a new tool. Give it a name for example grunt watch, in the program field enter grunt and in the parameter field watch. Set the working directory to your project using $ProjectFileDir$. After closing the settings view you should have new entry under Main Navigation -> Tools to run your grunt task from with WebStorm. You can also add short cut for the task in Preferences -> Keymap.

6 Responses
Add your response

Hi Andreas,

I am using phpstorm on windows and i am trying to setup Grunt by using the external command line tools of php storm.. I created an external command, but when I start it, I always get the error:

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

Could you give me some directions or how I should configure the external run command?

Thanks for your help

Jan

over 1 year ago ·

Sadly OSX 10.8 or hight doesn't support the .plist fix.
I tried the alternate solution, editing launchd.conf, but even after rebooting that didn't seem to affect the env variable for WebStorm (6.0.2). Additionally setting Path Variables in Webstorm has no effect from what I've been able to tell. (at least setting PATH in it does nothing)

Is anyone able to get this working with OSX10.8 > and WS 6.0.2 ?

over 1 year ago ·

Launch Webstorm from terminal:
open -a webstorm

over 1 year ago ·

@janwidmer : In Windows, you have to add the .cmd extension to "grunt". So, in the program field it would be "grunt.cmd".

over 1 year ago ·

@piosko: At some point I tried that..Eventually I brought it to work, but it was also really unstable, so it often stopped working.. So I went back to the external command line. Thanks for the input though.

over 1 year ago ·

Thanks for the tip, this worked for me on phpStorm 7, Mac running maverick

over 1 year ago ·