简体   繁体   中英

How to downgrade NPM package via CLI to an older minor version with using tilde version tag?

I have Typescript version ^3.7.4 installed as a devDependency in package.json :

{
  "name": "my-awesome-package",
  "version": "1.0.0",
  "devDependencies": {
    "typescript": "^3.7.4"
  }
}

I want to downgrade Typescript locked to the minor version 3.5, but with the newest patch versions applied . So the correct SemVer version tag would be with the tilde character, so ~3.5.0 in this case.

Which NPM command to run for this downgrade?

I have tried running npm i -D typescript@~3.5.0 , however after the installation package.json has "typescript": "^3.5.3" instead of "typescript": "~3.5.3" that I was expecting...

Using NPM version 6.9.0 and Node 12.5.0.

I couldn't find a way around this from some quick tests. I did find some issues around the topic though, so perhaps it is a bug. I would suggest that you open an issue on the new npm/cli repo as these issues are all on an archived repository so maybe they have been forgotten slightly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM