pnpm/pnpm · error · PnpmError

MISSING_RUNTIME_NAME

MISSING_RUNTIME_NAME

Error message

"pnpm runtime set <name> <version>" requires a runtime name (e.g. node, deno, bun)

What it means

Inside `pnpm runtime set`, the first remaining parameter is the runtime name; it is trimmed and required, and an empty result throws MISSING_RUNTIME_NAME with the expected shape ('pnpm runtime set <name> <version>' requires a runtime name (e.g. node, deno, bun)). This is the first of three validation layers in runtimeSet (name presence, name validity, version comma check) before anything is passed to the install pipeline.

Source

Thrown at pnpm11/engine/runtime/commands/src/runtime/runtime.ts:104

    })
  }
  switch (params[0]) {
    case 'set': {
      runtimeSet(opts, params.slice(1))
      return
    }
    default: {
      throw new PnpmError('RUNTIME_UNKNOWN_SUBCOMMAND', `Unknown subcommand: ${params[0]}`, {
        hint: help(),
      })
    }
  }
}

function runtimeSet (opts: RuntimeCommandOptions, params: string[]): void {
  const runtimeName = params[0]?.trim()
  if (!runtimeName) {
    throw new PnpmError('MISSING_RUNTIME_NAME', '"pnpm runtime set <name> <version>" requires a runtime name (e.g. node, deno, bun)')
  }
  // The runtime name is interpolated into an `add` selector, so reject
  // anything that isn't a known runtime before it can be misread as a
  // comma-separated package list or a local path by the install pipeline.
  if (!isRuntimeAlias(runtimeName)) {
    throw new PnpmError('INVALID_RUNTIME_NAME', `"${runtimeName}" is not a supported runtime. Supported runtimes are: ${RUNTIME_NAMES.join(', ')}`)
  }

  const versionSpec = params[1]?.trim()
  // The version is interpolated into the same selector, which the global-add
  // pipeline splits on commas. Reject a comma so `runtime set node 22,evil -g`
  // can't smuggle in a second install target. No valid runtime version
  // (semver, dist-tag, channel) contains one.
  if (versionSpec?.includes(',')) {
    throw new PnpmError('INVALID_RUNTIME_VERSION', `Invalid runtime version "${versionSpec}": a version cannot contain a comma`)
  }

  const args = ['add', `${runtimeName}@runtime:${versionSpec ?? ''}`]

View on GitHub (pinned to 5b11d3a15b)

Solutions

  1. Provide one of node, deno, or bun: `pnpm runtime set node 22 -g`.
  2. Default script variables: `pnpm runtime set "${RUNTIME:-node}" "${VERSION:-lts}" -g`.
  3. Check `pnpm runtime set --help` if unsure of the argument order.

Example fix

# before
pnpm runtime set -g          # ERR_PNPM_MISSING_RUNTIME_NAME
# after
pnpm runtime set node 22 -g
Defensive patterns

Strategy: validation

Validate before calling

const runtimeName = params[0]?.trim()
if (!runtimeName) {
  throw new Error('pnpm runtime set requires a runtime name: node, deno, or bun')
}

Prevention

When it happens

Trigger: `pnpm runtime set` with no further arguments, or `pnpm runtime set '' 22` where the name trims to empty.

Common situations: Scripts forwarding an unset runtime variable; users expecting an interactive prompt; copy-paste commands missing the name token.

Related errors


AI-assisted analysis of pnpm/pnpm@5b11d3a15b (2026-08-16). Data as JSON: /api/errors/9999499adb180415. Report an issue: GitHub.