David Ehrmann
David Ehrmann

Reputation: 7576

Correct way to put node_modules/.bin on PATH for WebStorm

I'm using WebStorm for a fairly straightforward project using Node, NPM, and Gulp. One of my Gulp tasks ends up doing gulp lint in a subprocess, and unless I have gulp on my PATH, I get

[14:20:37] Starting 'lint-parallel'...
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn gulp ENOENT
    at exports._errnoException (util.js:1018:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

So my question: what's the correct way to set up WebStorm so node_modules/.bin is on my PATH? I ended up setting PATH in Gulp Settings → Environment to node_modules/.bin:<rest of path>, but it felt very manual for pretty basic behavior. Or should I have PATH=node_modules/.bin:$PATH in my shell profile and let WebStorm pick it up that way?

Upvotes: 1

Views: 863

Answers (1)

lena
lena

Reputation: 93868

WebStorm inherits your interactive shell environment when being started from terminal, and uses environment variables configured in ~/.profile (login shell) when launched from Desktop or System menu. So you need to make sure that node_modules/.bin is added to your $PATH in the corresponding config to get it picked up

Upvotes: 2

Related Questions