Skip to main content

Module npm

Module npm 

Source
Expand description

A built-in npm client, so packages install without Node: it resolves versions from the registry, verifies and unpacks tarballs into node_modules and installs dependencies, hoisting them where Node’s resolution allows. It runs no lifecycle scripts, so native addons stay unbuilt, and an extension that loads one fails then. Installs return the tree they unpacked as pins, which replay reproduces without the registry.

Structs§

Installed
What install installed.
Npm
A registry client with a per-run packument cache.
Pinned
One package of an installed npm tree, as a lock pins it.

Enums§

NpmError
Why an npm operation failed. Its message escapes unprintable characters, which names and URLs from a lock or a registry may hold.

Functions§

check_name
Fails unless name is an npm package name, name or @scope/name, which keeps it inside the node_modules it is joined to. As npm, it accepts only URL-safe characters and no leading _. No part may start with ., so that none is .git or another hidden folder. The name is ASCII, so folding its case needs no Unicode rules.
config
npm’s configuration as the npm install pi runs reads it: the user config file (npm_config_userconfig, else ~/.npmrc) under npm_config_* environment variables, with ${VAR} references expanded.
fetch
Downloads name (at range, else the latest version), verifies its tarball and unpacks it in place of dir, without its dependencies. Returns its pin, whose path is empty: the package is dir itself.
fetch_pinned
Reinstalls the package pin records, as fetch returned it, in place of dir, under the download rules of replay. Its path is ignored.
install
Installs name (at range, else the latest version) into the npm root root, and records it in the root’s package.json. The caller holds the root’s lock_root.
install_dependencies
Installs the dependencies of the package in dir (a git checkout) into its own node_modules, and returns a pin for each package it unpacked, with paths below dir, as Installed::tree lists them. Fails when the checkout links node_modules or a scope folder in it elsewhere.
newer
Whether version candidate is later than current, as node-semver’s gt compares them, ignoring surrounding whitespace. None when either is not a version, where gt throws.
replay
Replaces root/node_modules with exactly the tree pins records, as Installed::tree lists it, without packuments or range resolution.
satisfies
Whether installed version satisfies range.
uninstall
Removes name from the npm root root, then the packages nothing depends on any more, name included unless another package needs it.