Installing Node with nvm manually in Rust build

Hello,

I have a small native Node add-on written with Rust, using Neon for bindings. I need to install Node and nvm manually in order to execute the neon compile command which builds the binary.

After much difficulty I have managed to get Travis installing Node via nvm and AFAICT the path to the Node exe is in PATH, however when yarn runs to install dependencies for the project it can’t find Node. If I run node --version it errors with “node command not found”. So clearly I am not adding Node to the PATH correctly, but I don’t see how.

Repository with travis.yml: https://github.com/sdgluck/node-crossterm

Relevant before_install command: https://github.com/sdgluck/node-crossterm/blob/master/.travis.yml#L106

Most recent Travis build: https://travis-ci.com/sdgluck/node-crossterm/jobs/19277779

Some fresh eyes would be much appreciated. How can I get yarn to see Node?

Thank you!

Node.js jobs on Windows are using nvs to install Node.js runtimes instead of npm.

See NPM not in path

Could you give that a try?

Thanks!

Here’s a handy recipe that you can copy/paste:

before_install
  - export NVS_HOME=$ProgramData/nvs
  - git clone --single-branch https://github.com/jasongin/nvs $NVS_HOME
  - source $NVS_HOME/nvs.sh
  - nvs --version
  - nvs add $TRAVIS_NODE_VERSION && nvs use $TRAVIS_NODE_VERSION
1 Like

I’ve been having the same issue, but the opposite way around, trying to run in the node environment but yarn can’t find rustc. https://github.com/elniallo/difficulty-neon. Will try the above and see if it solves the issue

Edit:
Including the above fixed the build error, however due to another issue with secure environment tokens, the build cannot be deployed to github
see this thread: Node.js build fails with no obvious error

Thank you @dominic, that works!

Now I have some new problems to battle. :sweat_smile:

1 Like

Glad to hear this worked, @sdgluck!

Please open a new topic if we can help you fight the other problems. :wink: