Chinaedu Onwukwe
Chinaedu Onwukwe

Reputation: 437

Specific Angular Cli Version is not installed

I need to install Angular CLI in the version 1.6.8. When I am executing this command:

npm install -g @angular/[email protected]

it is getting installed well. But when I am check the version using ng -v, it displays the latest version, in my case 1.7.4.

For my code compatibility, I need version 1.6.8. And even in my dependencies in package.json, I have specified the cli as version 1.6.8 :

"@angular/cli": "^1.6.8"

Does anybody know the issue? How can I install version 1.6.8?

Upvotes: 0

Views: 1389

Answers (2)

R. Richards
R. Richards

Reputation: 25161

This command will install the CLI globally on your machine.

npm install -g @angular/[email protected]

So, if you have an application that already has CLI version 1.7.4 included in it, you will see that version when you run ng -v. If you would like to downgrade to an earlier version, change the version in the package.json to the exact version you would like to use, and run npm install.

In your package.json you have this:

"@angular/cli": "^1.6.8"

What you need to change it to is this:

"@angular/cli": "1.6.8"

Remove the caret from the version number.

The caret tells npm that is can install versions of a library higher than what is listed, but only if the version is a minor or patch change. So, going from version 1.6.8 to 1.7.4 is OK, but it won't jump to version 6.0.0 when that comes out.

See here for more details.

Upvotes: 1

Vikas
Vikas

Reputation: 12036

if you are inside a directory that has node_modules ng -v would report that version, not the global one. For updating your global CLI, move to a directory that doesn't have node_modules installed and then execute

npm uninstall -g @angular-cli
npm cache clean
npm install -g @angular/[email protected]

You can change the version of the angular-cli in the package.json if you want to stick to the particular version remove the ^ symbol but this would be local

"@angular/cli": "1.6.8"

^ it means update the minor and patch version to the latest and keep the major version same.

Upvotes: 2

Related Questions