I'm confused by the intended behaviour of specifying "latest" as the version for a dependency in package.json and I'm hoping someone can explain it and/ or point me at where the behaviour is documented.
If I specify "@myPackageName": "latest
in my package.json and run npm install
, should it:
a) be equivalent to manually setting the version number in package.json to the latest available every time I run npm install,
b) be equivalent to specifying ">=0.0.0" - i.e. install the version that was the most recent at the time it is first installed, and after that follow the version specified in package-lock.json, or
c) Something else?
I had thought it would be (a), but experience so far looks like (b). Full details of what I've seen so far below:
- We have a npm package hosted in a private registry that we use in our project, and the latest version is, say, 1.0.2
- Our project currently has version 1.0.1 installed, and 1.0.1 is included in our package-lock.json
- Our dependencies in our package.json includes
"@ourPackageName": "latest"
npm view @ourPackageName@latest version
shows version 1.0.2- Running
npm install @ourPackageName@latest
installs version 1.0.2 and updates the package-lock.json to reflect that - But running
npm install
on its own does **not **install 1.0.2 or update package-lock.json