I'm using Fish shell/omf, NVM (https://github.com/derekstavis/plugin-nvm), and Sublime Text 3. I'm trying to use a build system to run nodemon (which I installed with npm -g install nodemon). nodemon works fine from within a native Fish shell:

~ » nodemon                                                                                                                                                                           15:47:56
  Usage: nodemon [nodemon options] [script.js] [args]

  See "nodemon --help" for more.

If I run which nodemon, I get:

~ » which nodemon                                                                                                                                                                     15:48:05
/Users/me/.nvm/versions/node/v7.5.0/bin/nodemon

(expected, from what I understand).

The problem:

Sublime doesn't seem to recognize the NVM path. Take this build system:

{
    "shell": true,
    "cmd": ["nodemon '$file'"],
    "selector":"source.js"
}

/bin/sh: nodemon: command not found
[Finished in 0.0s with exit code 127]
[cmd: ["nodemon '/Users/me/Dev/tmp/nodemon-test.js'"]]
[dir: /Users/brandon/Dev/tmp]
[path: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin]

I see that the path variable for Sublime doesn't have the NVM search path:

~ » echo $PATH                                                                                                                                                                        15:48:20
/Users/me/.nvm/versions/node/v7.5.0/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin

What's the correct way to fix this to make Sublime's $PATH match Terminal's $PATH? I'd expect it to continue to work even when I switch Node versions with NVM too.

Edit:

Yes, I'm using the omf solution for NVM, which works because I can run both nodemon and node from Terminal directly.

You can provide an option for the path in your build-file.

PS: I'm assuming you already set up fish to support nvm

  • Yes to your second point, but as for the path option, that means that each time I change node version I'm going to have to manually update that in the build system right? Unless NVM has some alias somewhere for "current version"? – brandonscript Feb 26 '17 at 18:08

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.