简体   繁体   中英

How to npm install and force latest version (permanently)?

I am deploying a private npm module for internal use at our company. Since the module is handled internally, we can trust version bumps etc.

How can I install the module in various projects so that the latest version of the module will always be installed with every single npm install , so that I don't have to go through a bunch of projects and update the version inside each package.json every time we deploy?

Please note that this should only be for selected packages, not all packages - ie only those hosted on our private server.

Use "*" as your version in your package.json file. For example:

"dependencies": {
 "my-awesome-repo": "*"
}

Upon npm install this will automatically install the latest version for "my-awesome-repo" that is availabile on npm.

One way is to run this before each install.

npm i -g npm-check-updates
npm-check-updates -u
npm install

On npm < 3.11:

"dependencies": {
 "express": "~3.2.0",
 "mongodb": "~1.2.14",
 "underscore": "~1.4.4",
 "rjs": "~2.10.0",
 "jade": "~0.29.0",
 "async": "~0.2.7"
}

You could try using the following package, which allows version selection by dist tag rather than a semantic version (eg latest ).

https://www.npmjs.com/package/package-json

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