nodejs/node · error · Error

Missing script: "${event}"${suggestions} To see a list of s

Error message

Missing script: "${event}"${suggestions}

To see a list of scripts, run:
  npm run${wsArg}

What it means

Thrown by `npm run` when the requested script name is not a key in package.json's `scripts`, and the special-case `start`-on-a-server-package fallback does not apply. npm collects the script name, checks `hasOwnProperty`, then (unless `--if-present`) raises this error with a did-you-mean suggestion.

Source

Thrown at deps/npm/lib/commands/run.js:115

      const { isWindowsShell } = require('../utils/is-windows.js')
      scripts.env = isWindowsShell ? 'SET' : 'env'
    }

    pkg.scripts = scripts

    if (
      !Object.prototype.hasOwnProperty.call(scripts, event) &&
      !(event === 'start' && (await runScript.isServerPackage(path)))
    ) {
      if (this.npm.config.get('if-present')) {
        return
      }

      const suggestions = require('../utils/did-you-mean.js')(pkg, event)
      const wsArg = workspace && path !== this.npm.localPrefix
        ? ` --workspace=${pkg._id || pkg.name}`
        : ''
      throw new Error([
        `Missing script: "${event}"${suggestions}`,
        '',
        'To see a list of scripts, run:',
        `  npm run${wsArg}`,
      ].join('\n'))
    }

    // positional args only added to the main event, not pre/post
    const events = [[event, args]]
    if (!this.npm.config.get('ignore-scripts')) {
      if (scripts[`pre${event}`]) {
        events.unshift([`pre${event}`, []])
      }

      if (scripts[`post${event}`]) {
        events.push([`post${event}`, []])
      }
    }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Run `npm run` with no args to list available scripts and confirm the exact name.
  2. Add the missing script to package.json `scripts` (e.g. `"build": "..."`).
  3. Use `--if-present` (`npm run build --if-present`) for optional scripts in shared tooling.
  4. Check you are in the correct workspace: `--workspace=<pkg>` or run from the right directory.

Example fix

// before
npm run biuld
// after
npm run build   // or add "biuld" to scripts
Defensive patterns

Strategy: validation

Validate before calling

function scriptExists(pkg, name) {
  return Object.prototype.hasOwnProperty.call(pkg.scripts || {}, name)
}
// wrapper:
if (!scriptExists(pkg, 'build')) {
  console.warn('No build script; skipping')
} else {
  run('npm run build')
}

Try / catch

try {
  await runNpm(['run', name])
} catch (e) {
  if (/Missing script/.test(e.message)) { /* optional script, ignore */ return }
  throw e
}

Prevention

When it happens

Trigger: Running `npm run <event>` where `scripts[event]` is absent and not (`event === 'start'` and `runScript.isServerPackage(path)` is true), with `--if-present` unset.

Common situations: Typing a script name wrong; expecting a script a dependency provides (e.g. `npm run build` when only `dist` exists); running in the wrong workspace/monorepo package that lacks the script; CI invoking a script removed in a refactor.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/e5f4e43cfbf0cb57. Report an issue: GitHub.