0

If I am installing a package using the @latest option the semantic versioning found for this package in the package.json is removed.

I have removed the package-lock.json file and the node_modules folder before doing the installation and this is still happening.

package.json before:

"dependencies": {
  "@awesomeproject/my_dep": "^1.0.4”,
}

Running:

npm install @awesomeproject/my_dep@latest

package.json after

"dependencies": {
  "@awesomeproject/my_dep": "1.0.5",
}

expected:

"dependencies": {
  "@awesomeproject/my_dep": "^1.0.5",
}

This is affecting only one specific package consistently. Other packages in the project are not affected, leading me to believe that this is something from that package and not from the project that is trying to update it. It should not be a problem changing anything in this package since I am the owner.

This is not the same problem as this question: Why does `npm install` add / remove caret (^) to / from version numbers? Since this is affecting all the packages.

EDIT: I want to save the newest version of the package to the package.json.

Andre Oliveira
  • 128
  • 2
  • 12

1 Answers1

0

Use the --no-save flag which prevents the update happening in your package.json

You need to run the command as,

npm install @awesomeproject/my_dep@latest ---no-save

Hope this helps!

David R
  • 14,711
  • 7
  • 54
  • 72
  • Hi David R, this works. However I want to save the newest version in the package.json. I'll update the question to reflect this. – Andre Oliveira Aug 07 '19 at 10:48