📎 Webclip
How to run multiple Node and Angular versions simultaneously
The article argues that switching between projects with different Node and Angular requirements is easier if each project keeps its own Node version and uses its local Angular CLI. It points out that Angular CLI is recorded in package.json, while Node version needs to be documented, and suggests nvm plus local CLI binaries as the practical setup.
Reading notes#
- nvm can install multiple Node versions and use different versions in separate shells.
- A normal workflow is to install each project’s Node version and run it in an independent shell for that project.
- Example projects XPTO and EPIC use Node 8.17.0 and 12.16.1.
- The command
nvm usesets the Node version for the current shell session, not only for one directory. - A new shell starts with the default nvm Node version unless something else is configured.
- The
.nvmrcfile lets a directory specify the Node version nvm should use there and in subdirectories. - The article says to use nvm commands such as
nvm runandnvm execso the.nvmrcfile is applied. - For Angular projects, the correct CLI version should come from the project’s local
node_modulesfolder. - Angular CLI is added as a development dependency in
package.json. - One option is to use
package.jsonscripts, sincenpm run-scriptaddsnode_modules/.binto PATH for the script. - Adding
"ng": "ng"as a script allows directnpm run nguse of the local Angular CLI. - Another option is to run
./node_modules/.bin/ngdirectly. - The article concludes that using nvm together with local Angular CLI binaries makes it possible to manage multiple versioned projects in a straightforward way.
