Changed behaviour of nvm alias after migrating to new machine image

Hi.

After moving to the recommended machine image ubuntu-2004:202201-02 from ubuntu-1604:202004-01, nvm alias default <some_version> is unexpectedly not persisted anymore for subsequent steps.

Related solutions like Nvm does not change Node version on machine did not work.

I figured out a workaround but would prefer that nvm alias works as officially documented and defaults are set for each step if configured.

What helped is adding nvm use default to the BASH_ENV after installing and aliasing the required node version, for example:

- run:
    name: "Setup node"
    command: |
      set -e
      nvm install v12.17.0
      nvm alias default v12.17.0
- run:
    name: "Enforce nvm use default"
    command: |
      echo "nvm use default" >> $BASH_ENV
2 Likes

Thank you for this information. I’ll update the migration guide with this info shortly, and look to getting this fixed in the next Ubuntu 20.04 release.

1 Like

@FelicianoTech this is still an issue with the latest ubuntu-2004:2022.10.1 image. The workaround that @Kaltenbach provided works for me too, so I’ll use that for now. It’d indeed be great if this could be fixed in the image. Thanks!