Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm update package --save removes some version range symbols (I have only tested ~ and ^) from package.json
Expected Behavior
It doesn't remove them.
Steps To Reproduce
- Fresh project created with
npm init
- With
package.json contents:
{
"name": "npmbug",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"emoji-poop": "~1.2.0"
}
}
- Run
npm update emoji-poop --save
- The version becomes
1.2.1 instead of ~1.2.1
Environment
- npm: 10.9.0
- Node.js: 20.11.1
- OS Name: Mac OS
- System Model Name: Macbook Pro M1
- npm config:
; "user" config from /Users/r.troha/.npmrc
<redacted>
package-lock = true
save-exact = true
save-prefix = ""
; "env" config from environment
python = "/opt/homebrew/python/bin/python3.8"
; node bin location = /Users/r.troha/.volta/tools/image/node/20.11.1/bin/node
; node version = v20.11.1
; npm local prefix = /Users/r.troha/Projects/npmbug
; npm version = 10.9.0
; cwd = /Users/r.troha/Projects/npmbug
; HOME = /Users/r.troha
; Run `npm config ls -l` to show all defaults.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm update package --saveremoves some version range symbols (I have only tested~and^) frompackage.jsonExpected Behavior
It doesn't remove them.
Steps To Reproduce
npm initpackage.jsoncontents:{ "name": "npmbug", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "emoji-poop": "~1.2.0" } }npm update emoji-poop --save1.2.1instead of~1.2.1Environment