Sublime Forum

Typescript build doesn't work with NVM install of Node

#1

I recently installed Node on El Capitan using NVM, so the path to Node is not /usr/local/lib/node_modules, it is in /Users/stevelombardi/.nvm/versions/node/v5.10.0/bin/node

I have tried the “fix mac paths” package, several other “fixes” I found on Stack Exchange. When I build TS files, I get the error

Cannot find node. Build cancelled.

This is with build 3109 on 10.11.4

Note that building TS files works fine in Atom, and works in Sublime if I launch it from the Terminal with the subl command.

Is there a way to fix this?

0 Likes

#2

… same issue here, macOS Sierra, nvm 0.32.1. As described, works when launched from the terminal window, shows ‘Cannot find node…’ when launching sublime from launchpad…

0 Likes

#3

Not sure why it didn’t work for @handycam, but did you try the Fix Mac Path plugin?

0 Likes

#4

I don’t have any experience with nvm, but assuming that Fix Mac Path doesn’t work, I would have to imagine that nvm is the reason why.

The git repository mentions a shell script that needs to be sourced and possibly some special command you need to use to either invoke node or tell the terminal which version to use for this session.

Specifically, it says this:

nvm use will not, by default, create a “current” symlink. Set $NVM_SYMLINK_CURRENT to “true” to enable this behavior, which is sometimes useful for IDEs. Note that using nvm in multiple shell tabs with this environment variable enabled can cause race conditions.

That makes it sound like the extra step may be needed. If that’s the case, I would imagine that the reason why it works when you run sublime from the terminal is because in that case you’ve already run the command that things up.

The plugin itself searches the path for the node executable and goes out of its way to also look inside $NVM_BIN for the binary. Ensuring that that variable it set to the correct value from your .bash_profile file may solve the problem as well.

In a pinch, you can add the node_path setting to your preferences file, and set it to the fully qualified path to the version of node that you want to use (including the name of the executable). For me (not using nvm) that would look like this:

 "node_path": "/home/tmartin/local/nodejs/bin/node"
0 Likes