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
installinstalled. - 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
nameis an npm package name,nameor@scope/name, which keeps it inside thenode_modulesit is joined to. As npm, it accepts only URL-safe characters and no leading_. No part may start with., so that none is.gitor another hidden folder. The name is ASCII, so folding its case needs no Unicode rules. - config
- npm’s configuration as the
npm installpi runs reads it: the user config file (npm_config_userconfig, else~/.npmrc) undernpm_config_*environment variables, with${VAR}references expanded. - fetch
- Downloads
name(atrange, else the latest version), verifies its tarball and unpacks it in place ofdir, without its dependencies. Returns its pin, whosepathis empty: the package isdiritself. - fetch_
pinned - Reinstalls the package
pinrecords, asfetchreturned it, in place ofdir, under the download rules ofreplay. Itspathis ignored. - install
- Installs
name(atrange, else the latest version) into the npm rootroot, and records it in the root’spackage.json. The caller holds the root’slock_root. - install_
dependencies - Installs the dependencies of the package in
dir(a git checkout) into its ownnode_modules, and returns a pin for each package it unpacked, with paths belowdir, asInstalled::treelists them. Fails when the checkout linksnode_modulesor a scope folder in it elsewhere. - newer
- Whether version
candidateis later thancurrent, as node-semver’sgtcompares them, ignoring surrounding whitespace.Nonewhen either is not a version, wheregtthrows. - replay
- Replaces
root/node_moduleswith exactly the treepinsrecords, asInstalled::treelists it, without packuments or range resolution. - satisfies
- Whether installed
versionsatisfiesrange. - uninstall
- Removes
namefrom the npm rootroot, then the packages nothing depends on any more,nameincluded unless another package needs it.