Contents

Managing multiple Angular CLI versions on the same computer

Contents

The Angular CLI. Who doesn’t love it? When they started this project, I thought to myself: “who needs this?” This is when it didn’t accomplish much and/or was full of bugs. But as the Angular team kept adding more features, it came to a point where I couldn’t resist it anymore. As I started using it for the first time, I quickly realized the power and potential this tool had. Now, I practically can’t live without it. And after maintaining so many Angular projects and each at a different version, I had to find a really good way to use the locally installed Angular CLI version per project in an almost seamless way. Here I’m happy to share my findings.

NVM

NVM, which stands for Node Version Manager (https://github.com/nvm-sh/nvm), is by far one of the coolest tools you can leverage to switch between different versions of NodeJS previously installed. It also helps you to install new versions of NodeJS. This is needed as newer versions of Angular CLI stop supporting older versions of NodeJS. So make sure you get this installed before you proceed. It will make your life a lot easier!

NPX

NPX is a command that “executes [any given command] either from a local node_modules/.bin, or from a central cache, installing any packages needed in order for [the given command] to run.” See https://www.npmjs.com/package/npx. What this means to you as an Angular developer is that you can safely run Angular CLI commands from the project’s installed version easily by preceding every ng command with npx.

This can be done on your local machine or in a CI/CD pipeline. As long as you have npm version 5.2+ installed on the system, you would be able to enjoy this liberating experience.

Did you ever dream of a world with no more Angular CLI conflicts with the globally installed Angular CLI? Well, now it’s within your reach with the use of npx. Enjoy!

I hope this was as useful for you as it was for me.