Bryan Irace
Bryan Irace

Reputation: 1875

Set Node.js environment variables in WebStorm

Is there any way to set environment variables when running a Node.js app using JetBrains' official Node plugin for WebStorm (and their other IDEs as well)?

Upvotes: 36

Views: 35333

Answers (3)

Ram Fattah
Ram Fattah

Reputation: 418

I'm new to JetBrains products, i'm not sure if this is the official solution.

Sharing the steps I took resolve this issue.

Note: I'm using NPM package manager.

In WebStorm menu, go to Run -> Edit Configuration -> click + -> npm

then provide the following fields:

  • Package.json
  • Command: run
  • Scripts: start
  • Environment: MY_ENV_NAME=123456

Click Ok

enter image description here

Then select the run configuration:

enter image description here

Finally got the nodejs server up and running: enter image description here

Upvotes: 0

CrazyCoder
CrazyCoder

Reputation: 401975

No, it's not possible from WebStorm, environment variables should be defined in your system.

UPDATE: in the new versions it's possible to set environment variables in the Run/Debug configuration.

Upvotes: 9

xinbenlv
xinbenlv

Reputation: 952

It is actually possible Here is the official doc: http://www.jetbrains.com/webstorm/webhelp/run-debug-configuration-node-js.html

Here is my screenshotenter image description here

Upvotes: 51

Related Questions