packall

node

`.npmrc` discovery, which is the one part of the npm protocol that is not portable.

import { … } from "@packall/registry-npm/node";

Functions

loadNpmrc

Loads and merges .npmrc files.

Precedence, highest first:

  1. $NPM_CONFIG_REGISTRY / $npm_config_registrythe registry only
  2. an explicit --npmrc <path>
  3. $NPM_CONFIG_USERCONFIG
  4. ./.npmrc in the current directory
  5. ~/.npmrc

The environment sitting above the explicit path surprises people, and it is npm's own ordering — env beats every config file, and --npmrc names a file. It bites because npm run and pnpm run export npm_config_registry, so a run from inside a package script quietly takes the package manager's registry rather than the one in the file it was pointed at. The symptom is a 404 against registry.npmjs.org with a .npmrc that reads perfectly.

It reaches the default registry only. Credentials come from the files regardless, and a @scope:registry in a file still wins for its own scope, because the scope lookup happens before the default is consulted.

--registry outranks all of it, which is the escape hatch when something in the environment is deciding this and you would rather it did not.

npm also consults a global (prefix-level) config; it is omitted deliberately because it almost never carries registry credentials and locating it reliably means shelling out to npm.

const loadNpmrc: (options?: {
   readonly explicitPath?: string | undefined;
   readonly cwd?: string | undefined;
   readonly env?: Readonly<Record<string, string | undefined>> | undefined;
} | undefined) => Effect<LoadedNpmrc, never, FileSystem | Path>

resolveTls

Reads cafile and folds it in with the inline ca entries.

An unreadable cafile is a warning rather than a failure, and the two options were weighed: erroring would stop a run that a correctly-configured system store might well have completed anyway. What it must not do is stay quiet — a typo in the path would otherwise surface as a certificate error naming nothing, which is the exact experience this module exists to remove.

const resolveTls: (config: NpmrcConfig) => Effect<ResolvedTls, never, FileSystem>

Types

LoadedNpmrc

Where a config value came from, for --verbose reporting.

type LoadedNpmrc = {
   readonly config: NpmrcConfig;
   readonly sources: readonly string[];
   readonly tls: TlsSettings;
   readonly warnings: readonly string[];
}

ResolvedTls

TLS settings, and anything the reader should know about how they were reached.

type ResolvedTls = { readonly settings: TlsSettings; readonly warnings: readonly string[]; }

On this page