Page MenuHomePhabricator

Allow the build script to pick different nodejs/npm versions
Closed, ResolvedPublic


We are thinking of switching to Node.JS 4.x. In order to be able to test the services correctly (via service-runner docker-test) and build the node module dependencies correctly (via service-runner build --deploy-repo), service-runner's lib/docker.js needs to be able to select the correct versions of the nodejs and npm packages in the container.


Just as we do for selecting the right target and the set of additional packages to install in the container, the version of node should be made part of package.json:

  // ...
  "deploy": {
    "node": "version",
    // other deploy-related stanzas, such as "target" and "dependencies"

where version is the explicit Node.JS version to use (such as 0.10.40, 0.12, iojs-2.5, etc). If the node stanza is not supplied, the selected target's nodejs package should be used. To force official distro package usage, one can use "node": "system".


In order to be able to accommodate such a variety of packages on various Linux flavours, we should install them using nvm, which is able to download and install them all. Note that the nodejs and npm packages should still get installed alongside nvm; partly because of the user's possibility of specifying the system version, but mostly because installing these two packages pulls in all of the needed system dependencies (most notably, build-essential on Debian-based systems).