After reading NPM’s documentation, I decided to jot down some notes to clarify things for myself.
Module vs. Package
Module is anything that can be loaded with require() in a Node.js program:
- A folder with a package.json file containing a main field.
- A folder with an index.js file in it.
A package can be a multitude of things – URL, git URL, tarball, etc. – which resolve to a folder containing a program described by a package.json file. Note that it doesn’t mean it can be used in a
require(): one counter example is a package that provide a CLI and not a library
What does NPM mean?
It could mean different things
- The website
- The package registry
- The NPM CLI
NPM packages are versioned using the following convention:
M- Major: updated when there are breaking changes to the package
m- Minor: when there are new feature, or changes that are non-breaking
p- Patches: used for patches or bug fix
Specifying versioning constraints:
- Tilde (~) or 1.0.x, allows for patch upgrades, but maintains the Major and Minor version
- Caret (^) or 1.x, allows for patch and Minor upgrades. Major version is fixed