npm study notes: foundation

npm consists of three distinct components

  • the website
  • the Command Line Interface (CLI)
  • the registry

Use the website to discover packages, set up profiles, and manage other aspects of your npm experience.

The CLI runs from a terminal, and is how most developers interact with npm.

The registry is a large public database of JavaScript software and the meta-information surrounding it.

 

It contains a variety of packages and Node moudules in the npm registry.

npm registry is the smallest element in the package and module.

What is the package?

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.

So what kind of package formats is it?

  • a) A folder containing a program described by a package.json file.
  • b) A gzipped tarball containing (a).
  • c) A URL that resolves to (b).
  • d) A <name>@<version> that is published on the registry with (c).
  • e) A <name>@<tag> that points to (d).
  • f) A <name> that has a latest tag satisfying (e).
  • g) A git url that, when cloned, results in (a).

What is a module?

A module is any file or directory in the node_modules directory that can be loaded by the Node.js require() function.

In order to be () function reference in Node.js require, module must be in the following format:

  • A folder with a package.json file containing a "main" field.
  • A folder with an index.js file in it.
  • A JavaScript file.

In general, npm is a tool for managing packages.

 

reference:

https://docs.npmjs.com/about-npm/

Guess you like

Origin www.cnblogs.com/colin220/p/11527271.html