8/11/2017 - 5:27 AM

Node.js: package.json Notes

Node.js: package.json Notes

package.json Notes

Versioning Levels

  1. Major: X.0.0
  2. Minor: 0.X.0
  3. Patch: 0.0.X

Fixed Version

"version": "1.2.3"

If it is likely that the project will break after the version number changes, then configure a fixed version number.

~ Operator

"version": "~1.2.3"

The ~ operator allows a version level to be updated at the patch level. For example, if version 1.2.3 updated to 1.2.4.

>= Operator

"version": ">=1.2.3"

The >= operator allows all version levels to be upgraded.

* Wildcard

"version": "*"

The * wildcard will grab latest version but should only be used with devDependencies or dependencies used for testing purposes which do not affect app behavior.

npm shrinkwrap

npm shrinkwrap will create a npm-shrinkwrap.json file which locks all dependencies for restricted versioning.


"scripts": {
  "start": "node app.js",
  "clean": "rm -rf node_modules",
  "test": "node test.js"
  • npm run start or npm start
  • npm run clean (bash)
  • npm run test or npm test