Notes on NPM

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 JavaScript file.

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 arequire(): one counter example is a package that provide a CLI and not a library

What does NPM mean?

It could mean different things

  1. The website
  2. The package registry
  3. The NPM CLI

NPM versioning

NPM packages are versioned using the following convention:

M.m.p

Where

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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s