简体   繁体   中英

Using NPM install highest semver major version X

Using package.json and NPM how can I install, using the command line, the highest number of major version 1 or major version 2?

In this case, I want to downgrade a package from version 2.xx to 1.xx And this case, I want x to be the biggest number possible.

Something like:

npm install foo@latest:1

I am not sure. My end goal is to get the right data into package.json, such that I never jump to version 2.0.0, and always remain at the highest 1.xx version.

Is there something I can manually insert into package.json? then run npm install foo ?

Unfortunately the NPM article on semver is not helping much.

If you're wanting to always pick the latest and greatest for a particular version but not wanting to jump major version then you can use the ^ prefix in the package.json.

Example:

"dependencies": {
    "nodemailer": "^2.3.2"
  },

Note: The latest major release for nodemailer is version 4 .

This will resolves to nodemailer@2.7.2 , which is the last release for version 2 .

Doing npm install produces the following

Output:

npm WARN deprecated nodemailer@2.7.2: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN deprecated CSSselect@0.3.11: the module is now available as 'css-select'
npm WARN deprecated CSSwhat@0.4.7: the module is now available as 'css-what'
nodemailer@2.7.2 node_modules/nodemailer

Reference: http://fredkschott.com/post/2014/02/npm-no-longer-defaults-to-tildes/

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