How do I set up a custom node version on a machine executor




I’m trying to setup a custom node version when running the machine executor on the default machine image. I can install any nodejs version I want directly using sudo apt-get, but that installs to nodejs and not node. There’s already an existing node binary pre-installed, but the version on that is too old.

I’m unable to delete that node binary and replace it with a symlink to the nodejs version I’ve installed because the pre-installed node version comes from an internal nvm installation. I CAN access the nvm installation and just directly run nvm install v9 ONLY ON a debug SSH session. When I actually copy the same line I run on ssh and try to add it as a run statement to my config.yml, the build breaks with a nvm: command not found error.

Others have recommended just using the node docker executor with the node version I want, but I don’t believe I can do that because I need a machine that also has the docker daemon installed, since, as a part of my test suite, I’m building and running docker images.

The short of it really is: I want an environment which has node v9.x.x and the docker client AND docker daemon. I can run my test suite correctly if I have an environment with those parameters


There’s a few strategies I can think of to solve this.

OK. So it sounds like you are running node with no fully-qualified path. So the first thing I would try is changing that to a fully-qualified path of a symlink pointing to v9. For example, if you are running node run-me.js presently, then this would turn to /usr/sbin/node run-me.js (I don’t know exactly what a NodeJS console command looks like, but you get the idea).

However, if you can’t change that because the binary name is buried somewhere you can’t change, you could hack the system PATH to get it to see your version first. So, let’s say your symlink to v9 is in /usr/sbin/node, then you could do this:

PATH=/usr/sbin:$PATH sh ./

That will temporarily modify the search order to prefer your binary/symlink over the usual one.

The good news is that is possible :smile:


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.