Boommeister
Boommeister

Reputation: 2127

Installing a specific version of angular with angular cli always ends up with the wrongversion

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 13.1.1
Node: 14.15.4
Package Manager: npm 6.14.10
OS: win32 x64

Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1301.1
@angular-devkit/core         13.1.1
@angular-devkit/schematics   13.1.1
@angular/cli                 13.1.1
@schematics/angular          13.1.1

So I did:

npm uninstall -g @angular/cli

-> confirming with ng --version that it has been removed. It has.

npm cache clean --force

then npm install -g @angular/cli@11

I also repeaded the steps and then ran npm install -g @angular/[email protected] at the end.

But I keep getting the same result as posted above when I run ng --version again (Angular/Cli is still at version 13.)

In my project I now changed everything in package.json to version 11, then removed the node_modules folder, ran npm install again and ng serve works. But when I run npm run build, it still says:

This version of CLI is only compatible with Angular versions ^13.0.0 || ^13.1.0-next,
but Angular version 11.2.14 was found instead.

my package.json:

"dependencies": {
    "@angular/animations": "~11.0.0",
    "@angular/common": "~11.0.0",
    "@angular/compiler": "~11.0.0",
    "@angular/core": "~11.0.0",
    "@angular/elements": "^11.0.0",
    "@angular/forms": "~11.0.0",
...
}

I know this question has many answers already in this question, but the answers don't work for me: I have Angular/CLi 13 installed, but I need to go back to version 11 for my project:

Upvotes: 1

Views: 10062

Answers (2)

Mthunzi Desmond
Mthunzi Desmond

Reputation: 11

npm install --force

It will solve all your issues.

Upvotes: 1

script0
script0

Reputation: 397

You change your global version of Angular CLI. Is your local version (project version) is 11.0? Inside your project folder, Try:

npm uninstall @angular/cli
npm install @angular/[email protected]

There is not -g argument now.

Upvotes: 2

Related Questions