Creating an Angular Project for a Specific Semantic Version

Ole Ersoy
1 min readNov 21, 2023

--

Image by Veronika Andrews from Pixabay

Scenario

We just upgraded global Angular CLI to version 17.0.0 . However we need to create a project with the semantic Angular version being 16.2.x .

Approach

One way to do this is to prefix the ng command with npx -p @angular/cli@16.2.x like this.

npx -p @angular/cli@16.2.x ng new angular-project

If you look at the package.json dependencies, you’ll see that the core @angular packages version numbers start with 16.2 .

 "dependencies": {
"@angular/animations": "^16.2.0",
"@angular/common": "^16.2.0",
"@angular/compiler": "^16.2.0",
...

However with that approach the global Angular CLI version remains what it was before, and we probably want the two to be synchronized.

To keep them synchronized install the version of the Angular CLI that we want first. So suppose we want the last major version of the Angular CLI for Angular major version 15 . Install that like this.

npm install -g  @angular/cli@15.x.x  

This will install this version of Angular.

ng version

Angular CLI: 15.2.10

And now we can just create projects the way we usually do and they will be for this version of Angular.

--

--