CrazySynthax
CrazySynthax

Reputation: 14998

Using caret sign (^) in package.json doesn't upgrade minor version

In my package.json file I have the line:

"typescript": "^4.1.6",

The caret sign(^) says that if there is a minor typescript version higher than 4.1, npm will install this version.

However, when I run "npm list", I see that the installed Typescript version is exactly 4.1.6. I can see here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html that there are handful of minor Typescript versions above version 4.1, so why am I still getting 4.1.6?

Upvotes: 0

Views: 783

Answers (3)

Dimava
Dimava

Reputation: 10841

Package managers read node_modules, skipping packages that are already installed.
Package managers have lock files, preventing changing the installing version.
Just npm install won't work

Run npm up (short for npm upgrade) or npm up typescript to update the package to its latest available version.

Upvotes: 0

CrazySynthax
CrazySynthax

Reputation: 14998

Once I:

  1. deleted the package.json file
  2. deleted the entire node_modules folder
  3. ran "npm install" again

I saw that Typescript version 4.9.5 was installed

Upvotes: -1

tom
tom

Reputation: 10529

With npm outdated you can see a list of available updates.

You can also use an online tool https://pkgui.com/npm

npm list only lists all the packages installed locally.

Upvotes: 1

Related Questions