Run Configuration with NPM

To build my local environment, I open up terminal and type "npm run start."  I tried to create a Run Configuration for this, but "run" isn't an option for command.  It only has "run-script," which throws an error.  Obviously typing "npm run start" isn't too much of a hassle; however, I would prefer just to click a button.  How can I set up Run Configuration for this?  


Thanks.

0
6 comments

You have 2 options here:

1. Run | Edit Configurations, press '+', choose 'npm', specify 'start' as 'Scripts':

2. right-click your package.json, choose 'Show npm scripts'; in NPM tool window right-click 'start' script, choose 'Edit settings' - run configuration will be created

 

>It only has "run-script," which throws an error.

 

what error? What configuration did you try?

2
Avatar
Permanently deleted user

This is the error I get:

0

From screenshot it seems that `npm run common:install && ...` command fails because `npm` is not a known command. Most probably npm is not in your $PATH. Try starting WebStorm from terminal - does the problem persist? Also, what OS are you on - Linux or MacOSX?

1
Avatar
Permanently deleted user

Aha!  Running it from terminal did the trick.  Any reason why?  I'd rather just use the icon on my dock to start WebStorm.  Mac OSX, btw.

0

Thanks for update:)

On MacOSX the environment variables differ between GUI applications and within the terminal.  Terminal environment is only available to applications started from terminal. Seems $PATH value does include npm in terminal environment, but not in GUI.
To solve this problem, WebStorm tries to load terminal environment by executing the following command on startup:

<your shell> -l -i -c '/Applications/WebStorm.app/bin/printenv.py'

Seems this command can't retrieve all needed stuff in your case - thus the issue.

Some links you may find useful: http://apple.stackexchange.com/questions/106355/setting-the-system-wide-path-environment-variable-in-mavericks, https://devnet.jetbrains.com/docs/DOC-1160#comment-2801, http://apple.stackexchange.com/questions/51677/how-to-set-path-for-finder-launched-applications.. The problem is that the way to define system-wide environment variables on Mac changes from one version to another (even minor system updates may break your environment)

 

1
Avatar
Permanently deleted user

Excellent information!  Thank you very much!!

0

Please sign in to leave a comment.