pnpm/pnpm · error · PackageManifestError
ERR_PNPM_NO_SCRIPT
ERR_PNPM_NO_SCRIPT
Error message
Missing script: {_0:?} What it means
PackageManifest::script(command, if_present=false) raises ERR_PNPM_NO_SCRIPT when scripts.<command> is absent from package.json (lib.rs:467). The `pnpm run` / `pnpm <script>` path surfaces it (cli run.rs converts it into RunError::NoScript with a hint). With --if-present the same lookup returns Ok(None) instead of an error.
Source
Thrown at pnpm/crates/package-manifest/src/lib.rs:55
code(ERR_PNPM_PACKAGE_JSON_EXISTS),
help("Your current working directory already has a package.json file.")
)]
AlreadyExist,
#[from(ignore)] // TODO: remove this after derive(From) has been removed
#[display("invalid attribute: {_0}")]
#[diagnostic(code(ERR_PNPM_PACKAGE_MANIFEST_INVALID_ATTRIBUTE))]
InvalidAttribute(#[error(not(source))] String),
#[from(ignore)] // TODO: remove this after derive(From) has been removed
#[display("No package.json was found in {_0}")]
#[diagnostic(code(ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND))]
NoImporterManifestFound(#[error(not(source))] String),
#[from(ignore)] // TODO: remove this after derive(From) has been removed
#[display("Missing script: {_0:?}")]
#[diagnostic(code(ERR_PNPM_NO_SCRIPT))]
NoScript(#[error(not(source))] String),
}
#[derive(Debug, Clone, Copy, PartialEq, IntoStaticStr)]
pub enum DependencyGroup {
#[strum(serialize = "dependencies")]
Prod,
#[strum(serialize = "devDependencies")]
Dev,
#[strum(serialize = "optionalDependencies")]
Optional,
#[strum(serialize = "peerDependencies")]
Peer,
}
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BundleDependencies {
Boolean(bool),View on GitHub (pinned to 6261b7f388)
Solutions
- Check the exact key under scripts in package.json and fix the typo.
- Add the missing script to package.json.
- Run `pnpm run` with no arguments to list available scripts.
- Use `pnpm run <script> --if-present` when absence is acceptable.
Example fix
# before $ pnpm bulid ERR_PNPM_NO_SCRIPT Missing script: bulid # after $ pnpm build
Defensive patterns
Strategy: validation
Validate before calling
const pkg = require('./package.json');
function assertScript(name) {
if (!hasScript(pkg, name))
throw new Error('script not found: ' + name + '; available: ' + Object.keys(pkg.scripts || {}).join(', '));
} Type guard
function hasScript(pkg, name) {
return typeof pkg.scripts?.[name] === 'string';
} Prevention
- List scripts with `pnpm run` before hard-coding names in CI.
- Use --if-present for optional lifecycle scripts.
- Rename scripts in lockstep with the CI pipelines that call them.
When it happens
Trigger: Run `pnpm build` or `pnpm run test` in a package whose scripts object lacks that key; typo in the script name; running in the wrong package of a monorepo where the script exists only in a sibling.
Common situations: Fresh clone before script setup; renamed scripts; monorepo root vs package confusion; CI invoking a script name that drifted from package.json.
Related errors
- readPackage hook returned package manifest object's property
- RECURSIVE_FAIL
- NO_PKG_MANIFEST
- ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL
- Failed to save the manifest file: {_0}
AI-assisted analysis of pnpm/pnpm@6261b7f388 (2026-08-17).
Data as JSON: /api/errors/eb7ede339957f7bd.
Report an issue: GitHub.