I have version 17 of Angular CLI installed globally on my machine, however I would like to use version 15 of Angular in a specific project, how can I do this locally without having to change the global version? What is the best practice to do in this regard?
First create a new folder, say its myProject
.
Then go inside this folder and run the below npm command. Which installs the version of angular/cli
you need which is different from the global version.
npm i @angular/cli@15.2.11
Now you have angular 15 installed inside this folder, now we will use this angular cli 15 to install the angular project using npx
command, the difference between npm
and npx
is that, npm
uses the globally installed version of a package, but npx
uses the local version of a package.
So using npx
we create the angular project using angular 15.
npx ng new testProject
Now you have an angular 15 project to start work on. But you have to use npx
commands whenever you face issues due to different version of angular, but this is very rare scenario.