The npm registry contains packages, many of which are also Node modules, or contain Node modules. Read on to understand how they differ and how they interact.
A package is a file or directory that is described by a package.json
file. A package must contain a package.json
file in order to be published to the npm registry. For more information on creating a package.json
file, see "Creating a package.json file".
Packages can be unscoped or scoped to a user or organization, and scoped packages can be private or public. For more information, see
A package is any of the following:
package.json
file.<name>@<version>
that is published on the registry with (c).<name>@<tag>
that points to (d).<name>
that has a latest
tag satisfying (e).git
url that, when cloned, results in (a).Git URLs used for npm packages can be formatted in the following ways:
git://github.com/user/project.git#commit-ish
git+ssh://[email protected]:project.git#commit-ish
git+http://[email protected]/project/blah.git#commit-ish
git+https://[email protected]/project/blah.git#commit-ish
The commit-ish
can be any tag, sha, or branch that can be supplied as an argument to git checkout
. The default commit-ish
is master
.
A module is any file or directory in the node_modules
directory that can be loaded by the Node.js require()
function.
To be loaded by the Node.js require()
function, a module must be one of the following:
package.json
file containing a "main"
field.package.json
package.json
In the context of a Node program, the module
is also the thing that was loaded from a file. For example, in the following program:
var req = require('request')
we might say that "The variable req
refers to the request
module".
© npm, Inc. and Contributors
Licensed under the npm License.
npm is a trademark of npm, Inc.
https://docs.npmjs.com/about-packages-and-modules