Can I work multiple angular versions in my computer?

Viewed 7308

I have installed Angular 7.2.0 globally on my Windows machine. Path is C:\Users\me\AppData\Roaming\npm\node_modules\@angular\cli, and I need to run older projects like Angular 6.0.0. So do I need to install both of versions on my machine in order to run the project?

3 Answers

If you install @angular/cli in each project locally using package.json, then you can use npx ng which will use the local version of the package.

So for example instead of doing: ng serve

You would instead do: npx ng serve

every angular project has locally a version of angular cli if the global cli has different version the local one will be used so in your case the local angular cli will run and build the project.

you will got a warinig message like this

Your global Angular CLI version (7.0.0) is greater than your local version (6.0.0). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".

npx way is good. In case if you don't have npx then you can direct use ng from node_modules like below

node_modules/@angular/cli/bin/ng serve
Related