2

After installing Node.js, I imported an Angular project from GitHub on VSCode, then I run the following usual commands successively:

npm install                      //This one created node_modules folder, but I don't have angular cli yet, because ng is still not recognized!
npm install -g @angular/cli      //Then after the installation of the global CLI finished..
ng --version

Now I get the following warning:

Your global Angular CLI version (7.3.5) is greater than your local version (7.3.2). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".

This question is trying to explain that warning, but they are not explaining where and when the local CLI is installed, at least in my case here.

Please give some clarification, thanks.

Edit

Here are the dependencies in pakage.json, according to your comments, they are related, but what is the usual scenarios if there is no explicit CLI version definition?.

    "dependencies": {
    "@angular/animations": "^7.2.6",
    "@angular/cdk": "^7.3.3",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/material": "^7.3.3",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "angular-formio": "^3.10.2",
    "bootstrap": "^4.3.1",
    "bootswatch": "^4.3.1",
    "core-js": "^2.5.4",
    "font-awesome": "^4.7.0",
    "jquery": "^3.3.1",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.1",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }
3
  • Doing npm install probably installs ng cli locally if specified in package.json file, it does not get automatically into PATH environment variable. To execute it you will need npx command i.e.: npx ng ..... Please post your devDependencies so we will be able to investigate. Commented Mar 12, 2019 at 18:41
  • @DariuszOstolski Thank you for note, I updated. Commented Mar 12, 2019 at 18:52
  • Try entering @angular/cli and version ~7.3.1 in the npm semantic version calculator. You'll see that version 7.3.2 could be installed based on that pattern. Commented Mar 12, 2019 at 18:54

2 Answers 2

4

The global version is installed with npm install -g @angular/cli@latest.

The local version is inside of your project in node_modules under node_modules/@angular/cli. You have to update your package.json to the same version as your global version.

The @angular/cli is installed locally when you run ng new appName.

And it is installed with every run of npm install in your project root.

To update it you need to change this line in package.json

...
"@angular/cli": "~7.3.2",
...

To this

...
"@angular/cli": "~7.3.5",
...

And then run npm install

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, That is the answer to Where, what about When?
@SourceCode It installed "locally" when you executed command npm install based on the version specified in package.json. What is the version number listed in package.json for @angular/cli?
@AlexanderStaroselsky Thank you, I updated, it does not seems to be the one in the message! No 3.2.
4

You have cloned an angular project from github, it has a file named package.json, which tells npm which packages to install when you do npm install.

So, in your package.json, please lookup for "@angular/cli" in devDependencies, you will find the version written something like this

"@angular/cli": "^7.3.2"

This is the local version of @angular/cli.

when you ran npm install, it installed that version(7.3.2) of Angular CLI, AKA local version.

but when you ran npm install -g @angular/cli, it automatically installed the latest version globally (the -g flag in the install command). And, the latest version was 7.3.5. Hence, it is giving the warning that the local version is not same and it is using the local version of Angular CLI

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.