I have a npm package in my package.json file
"clean-webpack-plugin": "^0.1.18"
Now when I hover over the package I can see that there is a newer version
"clean-webpack-plugin": "^0.1.19"
Now, as I understood, I could for example do npm update
to update all packages obeying the semver rules or just the package npm update clean-webpack-plugin
.
So the caret ^
symbol should mean, that you could possibly update the packge to version 0.9.9
if available, right?
npm update
has no effect, that's why I ask.
I'm quite certain that npm will have updated the application files for clean-webpack-plugin
from version 0.1.18
to version 0.1.19
after you run: npm update clean-webpack-plugin
as described in your question.
However, npm will not have updated the entry in your package.json
as theoretically it's not actually necessary to do so. Why?.. because version "^0.1.18"
is specified in package.json
. I.e. The version is specified with the caret ^
symbol.
Let's say your were to publish your project with ^0.1.18
specified in package.json
then any subsequent user running npm install
will actually get version 0.1.19
anyway (caveat: as the version history for clean-webpack-plugin
currently stands in the npm repository at the time of writing this).
So, in short I'm quite sure that version 0.1.19
has been installed on your system, it simply hasn't changed the version specified in package.json
. It's not actually necessary to do so and the rules of semver and the use of the caret symbol are still being respected.
So the caret
^
symbol should mean, that you could possibly update the package to version0.9.9
if available, right?
The caret in "^0.1.18"
is saying to npm I WILL accept any updates to the most recent MINOR version but I WILL NOT accept a MAJOR update. I.e. ^0.1.18
means any updates in the range >=0.1.18 <1.0.0
(PATCH updates within that range are allowed too).
Verifying whether it has been updated:
To verify whether version 0.1.19
has actually been installed you can cd
to your project directory and run:
npm ls clean-webpack-plugin
You should see the following logged to your console:
...
└── clean-webpack-plugin@0.1.19
But I want package.json
to show "^0.1.19"
after running npm update
:
When you initially run npm update clean-webpack-plugin
you could have:
--save-dev
argument (applicable if it was listed in your devDependencies
section of package.json
).--save
argument (applicable if it was listed in your dependencies
section of package.json
). Appending either --save-dev
or --save
as appropriate to npm update clean-webpack-plugin
would have update the entry in package.json
. This is further explained in the Recording Updates with --save
section of the npm documentation.
By doing this, you can think of it as re-specifying the initial >=
part of the range of updates you'll accept.
Note
Running npm update clean-webpack-plugin
with the additional --save
or --save-dev
argument will not have any affect if npm ls clean-webpack-plugin
reports:
...
└── clean-webpack-plugin@0.1.19
There would be nothing to update, so I'd just manually specify "^0.1.19"
in package.json
.