Skip to content

Commit

Permalink
chore(ci): use nvs on Windows
Browse files Browse the repository at this point in the history
Switch to installing node on Windows using NVS rather than NVM. NVS is
not installed by default, so use Chocolatey to install it.

NVM currently has two shortcomings that make it difficult to use in automation.

"nvm install 16 && nvm use 16" doesn't work because "use" appears to
need an exact patch version specified, which would involve parsing
the output of "install" or of "list" since we only lock to major verisons.
 coreybutler/nvm-windows#708

"nvm use" and "nvm install" both give successful exit statuses even when
they fail with an error message. This meant that when we did "nvm use
16", it failed because of the above bug, but the job kept on running and
used the default version of Node installed in the image. Working around
this would again involve parsing output.
coreybutler/nvm-windows#738

In my testing, NVS appears to have neither of these problems.

I had also considered installing Node directly via Chocolatey, but
Chocolatey does not yet support installing particular versions unless
the packager has appended the version number to the name. This also
implies that likely only the latest major version gets updates.
  • Loading branch information
daxelrod committed Jan 21, 2022
1 parent 6b7eb22 commit 5046c59
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ jobs:
executor: << parameters.os >>
steps:
- checkout
# The node orb is not compatible with Windows executors, but they already have nvm installed
# The node orb is not compatible with Windows executors, but they already have nvm installed.
# Unfortunately, https://github.com/coreybutler/nvm-windows/issues/708 means that we would
# need to specify an exact dot version of Node to use, and https://github.com/coreybutler/nvm-windows/issues/738
# means that nvm will silently fail. Instead, use nvs, which has addressed both of these problems.
- when:
condition:
equal: [ *windows-executor, << parameters.os >> ]
steps:
- run: nvm install << parameters.node-version >>
- run: nvm use << parameters.node-version >>
- run: choco install nvs
- run: nvs add node/<< parameters.node-version >>
- run: nvs use node/<< parameters.node-version >>
- run: npm install --global yarn
# All other executors can use the orb to install Node
- unless:
Expand Down

0 comments on commit 5046c59

Please sign in to comment.