0

I am working on two Angular projects. One is Angular 8 and another is Angular 11.

I installed Angular CLI using:

npm install -g @angular/cli

I then tried to build the Angular 8 project using the command:

ng build

But I got an error saying the CLI was the wrong version ...

How to install 2 versions of the CLI and choose which one to use?

Miguel Moura
  • 36,732
  • 85
  • 259
  • 481
  • have you tried NVM ? – Stavm Feb 18 '21 at 19:01
  • Does this answer your question? [angular-cli different versions in the same computer](https://stackoverflow.com/questions/43018777/angular-cli-different-versions-in-the-same-computer) – Joundill Feb 18 '21 at 20:05
  • 1
    Personally I use npx to init my project, then the same with ng commands. Example: `npx -p @angular/cli@8 ng new hello-world` for v8. Then you can run `npx ng ` like `npx ng build` – penleychan Feb 18 '21 at 20:06

2 Answers2

1

How to install 2 versions of the CLI and choose which one to use?

It's easy! Just install the needed version locally in the project folder and use whichever version you want for different projects.

npm install @angular/cli
T. Sunil Rao
  • 1,167
  • 5
  • 14
0

You can have the latest CLI version installed globally and chose the earlier CLI versions in your project based on your needs.

However, certain versions of CLI may need an old version of node JS and npm (node 11 vs node 8). In this case, you might would need to switch between node versions using nvm - https://blog.logrocket.com/switching-between-node-versions-during-development/