Nub reads your project's package-manager pin and runs that exact version under the project's Node. The first run fetches it from the npm registry, verifies its integrity, and caches it under ~/.cache/nub/pm.

nub install is separate: it always runs Nub's own engine, and the pin (or, without one, the lockfile) decides which manager's lockfile format, config files, and behavior it follows. Running the pinned manager itself, as a bare pnpm or yarn command, is what the shims are for.

$ nub pm which
/Users/you/.cache/nub/pm/pnpm/9.15.4/package/bin/pnpm.cjs
» resolved from packageManager ([email protected])

There is no corepack enable step and no built-in version table, so an older Nub binary still provisions today's pnpm.

Pin resolution

Nub reads the pin at the workspace root, in this order:

  1. .yarnrc.yml yarnPath — a committed Yarn Berry release
  2. package.json#/packageManager — the corepack field, an exact version ([email protected], optionally +sha512.<hash>)
  3. package.json#/devEngines/packageManager — { name, version }, where the version may be a range

Ranges belong in devEngines. For pnpm 11.1.3 and later, a range runs the version pnpm-lock.yaml records in packageManagerDependencies while the range allows it, as pnpm does. A range in packageManager still resolves to the newest matching release, with a warning for pnpm 10 and later, which ignore one there. A lockfile never implies a pin. With no pin, nub pm which errors and points at nub pm use.

CLI

The nub pm commands resolve, pin, and cache the package manager a project uses.

nub pm which

Print the resolved package manager, provisioning it if it isn't cached yet. The path goes to stdout and the provenance to stderr:

PM=$(nub pm which)   # the path only

nub pm use

Declare the project's package manager: npm, pnpm, Yarn, or Bun. The command resolves the version, fetches and verifies it, writes the pin, and converts the lockfile.

nub pm use pnpm           # newest pnpm (latest dist-tag)
nub pm use npm@10         # newest 10.x
nub pm use [email protected]    # exact
nub pm use yarn@4         # newest Yarn 4.x

A bare nub pm use yarn pins classic Yarn 1, unless the project's yarn.lock is already in Berry (Yarn 2+) format. Then it pins the newest Berry release.

Moving an npm project to pnpm:

$ nub pm use [email protected]
Fetching pnpm 11.5.3 (4 MB)...
using [email protected]
  package.json: packageManager = [email protected]
  package.json: devEngines.packageManager =
    { name: "pnpm", version: "11.5.3", onFail: "warn" }
  pnpm-lock.yaml: written (converted from package-lock.json)
  package-lock.json: removed (migrated)
  pnpm-lock.yaml: packageManagerDependencies = [email protected] (+integrity)

It writes three things, and rerunning it is a no-op:

  • package.json#/packageManager — the exact version plus a +sha512 hash from the verified tarball, the field corepack, pnpm, and turbo read
  • package.json#/devEngines/packageManager — { name, version: "^<exact>", onFail: "warn" }, the range-and-policy form npm and pnpm enforce
  • The lockfile, in the new manager's format — a lockfile in another format is converted with its resolution state and the old file removed; one already in the target format is left alone. For pnpm 11 and later, the pinned pnpm is also recorded in the lockfile's packageManagerDependencies, which pnpm's frozen install requires

For pnpm 11 and later, both fields hold the same exact version with no hash, because pnpm 11 warns when they disagree. The integrity goes in pnpm-lock.yaml instead, and a fresh download is checked against it. Until the lockfile records it, the hash stays in package.json, on packageManager alone before pnpm 11.8 and on both fields from 11.8. The converted lockfile passes the new manager's frozen install, such as pnpm install --frozen-lockfile.

Config is not migrated

Switching managers converts the lockfile, not your config. The .npmrc, any pnpm.* fields, pnpm-workspace.yaml settings, and other manager-specific config stay as they are.

Five cases stop the command before anything is written:

  • Multiple foreign-format lockfiles — remove the stale ones first.
  • A binary bun.lockb source — regenerate it as text first with bun install --save-text-lockfile.
  • Pinning Yarn 1 over a Berry yarn.lock — classic would downgrade the format.
  • Pinning Berry over another manager's lockfile — Nub doesn't convert to Berry's format; delete the old lockfile and Yarn writes yarn.lock on its first install.
  • Pinning Yarn 1 on a graph using the workspace: protocol — classic Yarn can't express it.

Running use bun writes the pin and lockfile but doesn't provision Bun.

nub pm pin

Pin the project to an exact Nub version, the running one by default. See pinning Nub itself for what the pin does.

nub pm pin           # pin the running Nub
nub pm pin 0.2.10    # pin an exact version
$ nub pm pin
pinned [email protected]
  package.json: packageManager = [email protected]
  package.json: devEngines.packageManager =
    { name: "nub", version: "^0.2.10", onFail: "ignore" }

It writes only the two pin fields, with no lockfile conversion or config migration; nub pm use nub is the full switch onto Nub. The version must be exact.

nub pm update

Bump the pin to the newest version satisfying the devEngines range, or the registry latest without one. A devEngines version that repeats the pin, as Nub writes for pnpm 11, moves with it within its major. The command provisions the new version and rewrites the pin, and for pnpm 11 and later its record in pnpm-lock.yaml. Under a range you wrote yourself, pnpm 11.1.3 and later keep the new version in pnpm-lock.yaml alone, and the command removes packageManager, which pnpm warns about when it differs from the range. Alias: nub pm up.

$ nub pm update
Fetching pnpm 9.15.9 (4 MB)...
updated pnpm 9.15.4 → 9.15.9

nub pm cache

List or clear the cached package managers, stored at ~/.cache/nub/pm/<pm>/<version>.

$ nub pm cache
[email protected]
[email protected]
$ nub pm cache clear

A cached exact pin runs offline. Nub contacts the registry only to resolve a range the lockfile doesn't record, or to fetch a missing version.

nub pm shim

Route bare pnpm, npm, and yarn commands through Nub to the pinned manager; nub pm unshim removes the shims. The shims are opt-in, since nub install and nub run work on Nub's own engine. See Corepack-style shims.

Pinning Nub itself

The packageManager field can also pin Nub. When the running Nub is a different version, it fetches that exact release, verifies its checksum, and hands off, so every contributor installs with the same Nub.

package.json
{
  "packageManager": "[email protected]"
}

Only the install verbs hand off:

$ nub install
nub: provisioning pinned [email protected] (darwin-arm64)...
nub: provisioned [email protected]

The file runner, nub run, nubx, version management, and self-update never read the pin. A corrupt, missing, or wrong-version release is a hard error. Provisioned releases are stored at ~/.cache/nub/self/<version> and run offline afterwards. A non-exact pin runs the installed Nub with a notice, since the packageManager field is exact-only.

To run your installed Nub regardless of the pin, set NUB_SELF_SHIM=0. It disables the handoff for the whole process tree:

NUB_SELF_SHIM=0 nub install

.npmrc

The package-manager download goes through your .npmrc: registry= picks the mirror, and //host/:_authToken= authenticates. Setting NPM_CONFIG_USERCONFIG moves the user file, and npm_config_registry or NPM_CONFIG_REGISTRY overrides registry=.

~/.npmrc
registry=https://npm.corp.example/artifactory/api/npm/npm/
//npm.corp.example/artifactory/api/npm/npm/:_authToken=${CORP_NPM_TOKEN}

Environment placeholders (${VAR}) expand in your user ~/.npmrc and in npm_config_* variables. A project .npmrc committed to the repo is read literally, so a cloned repository cannot send one of your secrets to a host it chooses. On trusted CI, set PNPM_CONFIG_NPMRC_AUTH_FILE=.npmrc to expand the project file too.

To fetch package managers from a different registry than your dependencies, set COREPACK_NPM_REGISTRY, with COREPACK_NPM_TOKEN for auth.

Read the full docs for the npmrc file on docs.npmjs.com.

  • nub.jsonc — the project file for Nub's own runtime, install, and temporary-run settings.
  • Package manager — the install engine, which the install block configures.