0

I have in my package.json this versions of dependencies

"dependencies": {
  "@angular/animations": "^4.1.3",
  "@angular/common": "^4.0.0",
  "@angular/compiler": "^4.0.0",
  "@angular/core": "^4.0.0",
  "@angular/forms": "^4.0.0",
  "@angular/http": "^4.0.0",
  "@angular/platform-browser": "^4.0.0",
  "@angular/platform-browser-dynamic": "^4.0.0",
  "@angular/router": "^4.0.0",


"devDependencies": {
   "@angular/cli": "1.0.6",
   "@angular/compiler-cli": "^4.0.0",

and in the project when execute ng -v

$ ng -v
@angular/animations: 4.2.4
@angular/common: 4.2.4
@angular/compiler: 4.2.4
@angular/core: 4.2.4
@angular/forms: 4.2.4
@angular/http: 4.2.4
@angular/platform-browser: 4.2.4
@angular/platform-browser-dynamic: 4.2.4
@angular/router: 4.2.4
@angular/cli: 1.0.6
@angular/compiler-cli: 4.2.4

what is the current version of @angular in the project 4.0.0 or 4.2.4?

0

2 Answers 2

4

The versions in package.json are version ranges.

For example, if the version of @angular/core there is ^4.0.0, this is like 4.x.x, so depending on the last time you ran npm install (with no arguments), the actual version of @angular/core you might have in node_modules might be 4.0.1 or 4.2.5 etc.

Another example is typescript. It might show in package.json as ~2.3.0, which is like 2.3.x, you actual version might be 2.3.4.

You can check the version truly installed of a package by running npm ls, for example npm ls typescript will show all versions of typescript package either called directly from package.json, or coming as a dependency of another package.

The Angular/cli version is very specific in your provided package.json, and set to 1.0.6.

You would also have a global install (not specific to the project that has the package.json file) of @angular/cli. You can check its version by running npm ls -g @angular/cli.

This is very close to ng -v. What ng -v tells you is:

  • What's the globally installed version of @angular/cli
  • What's the locally installed version of @angular/cli (the one in node_modules, not the range specific in package.json).
    This is important in case you have both, as having different versions of both might causes issues.
  • What are the locally installed versions (not the ranges) of other Angular packages that you need to ensure are in sync
Sign up to request clarification or add additional context in comments.

Comments

1

Your previous package.json did not have @angular/cli, If you talk about other packages in general, this will be the explanation: It is 4.2.4, the ^ says, take a package 4.0.0 or greater than that, while doing a fresh npm install you would have got the latest version. To stick to the same version on all development machines (if working in a team), I would recommend giving exact dependencies in package.json coz new versions might break the code in a fresh install.

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.