By default, you have 1 node.js and NPM version installed on your machine. However, if you have to maintain applications written in multiple Angular and/or Typescript versions, this can become a problem. Older Angular/Typescript applications are not compatible with the latest node.js version and can no longer be compiled.
In Linux, this has been solved by the introduction of nvm , the node version manager. With it, it is possible to quickly install(and uninstall) different node.js versions and easily switch between them via the command line.
NVM-Windows
With nvm-windows, an alternative is also available for Windows. You can easily install nvm-windows on your local machine via the installer available here: https://github.com/coreybutler/nvm-windows/releases .
Using nvm-windows is very simple:
- Install a node.js version:
nvm install <version>
- Listing the installed versions:
nvm list
- Switching between versions:
nvm use <version>
Note: Global packages(if used) must be installed per node.js version.
Using NVM-Windows on your build server
NVM-Windows is not only useful on your local dev machine but can be a big help on your build server as well. Install nvm-windows on your build server after which you can invoke it in your YAML templates:
Keep in mind that changing the node.js version is a global change that impacts all build agents.
So also remember to always reset the node.js version to the latest version in your build pipeline.