Quader Docs 0.176.0

npm

Install, publish and maintain npm packages with npm, pnpm and Yarn, and set up the repositories they use.

On this page

Configure the client

Set up client writes the configuration for npm, pnpm, Yarn Berry (2 and later) or Yarn Classic (1.x):

Client File Credential line
npm, Yarn Classic .npmrc in the project, or ~/.npmrc //<host>/api/npm/<project>/<repository>/:_authToken=${QUADER_TOKEN}
pnpm ~/.npmrc: pnpm 11 and 12 ignore a credential that names a variable in a project file as npm
Yarn Berry .yarnrc.yml in the project; Yarn Berry does not read .npmrc npmAuthToken: "${QUADER_TOKEN}"
ini
# .npmrc, example: the virtual repository npm of the project web
registry=https://quader.example.com/api/npm/web/npm/
//quader.example.com/api/npm/web/npm/:_authToken=${QUADER_TOKEN}
yaml
# .yarnrc.yml, example
npmRegistryServer: "https://quader.example.com/api/npm/web/npm/"
npmAlwaysAuth: true            # only when the repository is not public
npmAuthToken: "${QUADER_TOKEN}"

The credential line names the registry without its scheme, so the token goes to this repository only. Yarn needs npmAlwaysAuth: true (Classic: always-auth=true) for a repository that is not public, or it sends the token for scoped packages only; the snippets add it. To take one scope from Quader, write @your-scope:registry=<address> instead of registry= (Yarn Berry: npmScopes). npm login does not work: the token goes into the configuration. npm whoami prints your user name, sa:<name> for a service account.

Install, publish and maintain

shell
npm install <package>                        # pnpm add, yarn add
npm ci                                       # pnpm install --frozen-lockfile, yarn install --immutable (Classic: --frozen-lockfile)
npm publish                                  # pnpm publish, yarn npm publish (Classic: yarn publish --new-version <version>)
npm dist-tag add <name>@<version> <tag>      # pnpm dist-tag add, yarn npm tag add (Classic: yarn tag add)
npm unpublish <name>@<version>               # pnpm unpublish --force; Yarn has none
npm deprecate <name>@<range> "<message>"     # pnpm deprecate; Yarn has none
npm audit                                    # pnpm audit (pnpm 11 and later), yarn npm audit; not Yarn Classic

Installing needs read, publishing and dist-tags deploy, unpublishing delete (Permissions); through a virtual repository you also need read on the members you install from.

Class What a client meets
Local A name and version is published once (409 npm_version_exists); an unpublished number stays blocked (409 npm_version_unpublished). latest can be moved, never removed
Remote No writes (405 npm_class_not_writable); a package document is asked again after its metadata period
Virtual Publish, dist-tags and unpublish go to the deployment target; without one 405 no_deploy_target. pnpm 11 and 12 cannot unpublish through it: unpublish at the target

The first publish of a name to a local repository makes you its owner and claims the name, so a virtual repository never takes a public package of that name from a remote member (Protection against dependency confusion). npm publish --stage answers 501. What an endpoint with exposure rules serves of npm is on Endpoints.

Lockfiles

npm and Yarn Classic record each tarball's address and integrity; an install from the lockfile fetches those addresses, whatever the configuration says now. To move an npm lockfile to another repository with the same versions, replace the address in it; the integrity stays valid. pnpm checks the integrity in pnpm-lock.yaml; Yarn Berry writes no address into yarn.lock.

Integrity values hold because a local version's bytes never change, and a remote stores a tarball only when it matches its upstream's announced integrity. A version the upstream withdrew answers 404 through remote and virtual repositories, also for a lockfile, unless its remote serves removed versions. EINTEGRITY means the lockfile was written against a registry that served other bytes.

Through a Bastion the snippet adds replace-registry-host=always, so one lockfile works through this installation and the Bastion.

Audit and signatures

npm audit is answered as the repository's Security audit says (below); a local repository without Quader's advisory data answers 501 npm_audit_unavailable.

npm audit signatures checks registry signatures and provenance. A remote serves its upstream's keys and attestations. While an administrator has set up a signing identity (Signatures), Quader signs every version of a local repository shortly after its publish, and a virtual repository serves its members' keys with Quader's. Without one, a local repository serves no keys and the command reports your own packages unsigned. npm asks the public Sigstore service for keys first, so the machine needs to reach it.

Settings

Who
the project's Owner, and holders of repositories:write-config

A remote starts at npm public registry (https://registry.npmjs.org/), with a metadata period of 7,200 seconds and a remembered "not found" of 1,800 seconds. It always compares a tarball with the integrity its package document announces and refuses a mismatch (502 upstream_integrity_mismatch). The format's own settings are in npm settings:

Class Setting Default What it does
Local Guard the latest tag on A publish below latest, or a pre-release while latest is a release, leaves latest where it is
Remote Serve removed versions off Keeps serving cached tarballs the upstream removed, to exact downloads such as a lockfile's
Virtual Latest tag strategy Highest version Which latest members that differ give: the highest version or the newest published
Virtual Dist-tag strategy First member in order Which value the other dist-tags take: the first member's, the highest version or the newest published
Every class Security audit › Mode Automatic From Quader's advisory data sends nothing out; Forward to an advisory service passes the names of public packages to the upstream or Provider URL (remote and virtual); Off answers 501
Every class Timeout, Largest audit request 30s, 1MiB The wait for a forwarding provider, and the size of one request

Automatic answers from Quader's advisory data while vulnerability scanning is on and its OSV source is not off; else it forwards on remote and virtual repositories and is off on local ones. Without imported npm advisory data, the mode from Quader's data answers 503 vulnerability_data_unavailable.

The installation's limits of a publish (tarball size, entries) are the keys of npm.