I'm using Angular CLI 9.1.1 but need to create a project with Angular 8.
I also have other projects using Angular 9, so I don't want to install Angular 8 CLI globally.
Is there any option to create an Angular 8 project using Angular CLI 9?
I'm using Angular CLI 9.1.1 but need to create a project with Angular 8.
I also have other projects using Angular 9, so I don't want to install Angular 8 CLI globally.
Is there any option to create an Angular 8 project using Angular CLI 9?
You don't need a global install of Angular CLI. It's marginally more tiresome, but certainly less than juggling global installs. Here's the procedure:
npm init
and npm i @angular/cli@8
.ng new myapp
, run npx ng new myapp
.(Or at least it worked on my machine...)
May be you can think of npx
as well.
What npx
does is that it would install the nodejs package temporarily and then it would execute it. So this will allow you to use any version locally.
In order to achieve your goal you can execute this following command:
npx -p @angular/cli@8 ng new <your_project_name>
. This will create an angular project with version 8 and then you can go to project and use the normal npm
scripts commands from package.json
.
In this you do not need to install or downgrade your ng
version globally.
The tool npx
is pre-installed with npm v5.2.0+
If somebody still needs an angular 8 installation and it failed by using:
npm i @angular/cli@8
And it's showing this error:
npm ERR! Could not resolve dependency: npm ERR! peer jasmine-core@">=3.8"
Here is the fix:
npx ng new myapp --skip-install
cd myapp
Open the package.json and change jasmine-core to `~3.8.0`
npm i