Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm update to specific version (and shrinkwrap)

Tags:

node.js

npm

I'm using NPM and shrinkwrap (latest up to date version) to maintain my packages.

At the moment, one of my package current version is 1.1.0. The latest version of this package is 2.2.0.

I want to update/upgrade this specific package to version 2.0.0 (and not the latest 2.2.0).

I thought that the procedure would be:

  1. npm install in order to make sure that I'm synchronized with the npm-shrinkwrap
  2. npm update [email protected]
  3. npm shrinkwrap
  4. git add . && git commit -m "Updating package myPackage to version 2.0.0"

This doesn't seem to be the right road to go. It doesn't update the package.json and it always jump to the latest version. I have no control over this command to select the specific version I want.

I read the documentation about npm update and couldn't find the proper way to update the package to a specific version.

How to do this ? Would npm install --save [email protected] would be the correct procedure ? Then what will be the purpose of having npm update command ?

Solution: npm install [email protected] --save

like image 342
Yves L L Avatar asked Mar 15 '17 16:03

Yves L L


2 Answers

npm update doesn't seem to interact with the shrinkwrap file as far as I can tell. But you can use npm install to set the version of a package.

This will update both package.json and npm-shrinkwrap.json:

npm install [email protected] --save

like image 56
Gregory Bell Avatar answered Sep 17 '22 14:09

Gregory Bell


You can enter to package.jsonand write the version yourself on the dependencies. After that do npm install and it will install the correct version.

like image 31
Alan Avatar answered Sep 20 '22 14:09

Alan