{"record":{"id":"e5f4e43cfbf0cb57","repo":"nodejs/node","slug":"missing-script-event-suggestions-to-see-a","errorCode":null,"errorMessage":"Missing script: \"${event}\"${suggestions}\n\nTo see a list of scripts, run:\n  npm run${wsArg}","messagePattern":"Missing script: \"(.+?)\"(.+?)\n\nTo see a list of scripts, run:\n  npm run(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/commands/run.js","lineNumber":115,"sourceCode":"      const { isWindowsShell } = require('../utils/is-windows.js')\n      scripts.env = isWindowsShell ? 'SET' : 'env'\n    }\n\n    pkg.scripts = scripts\n\n    if (\n      !Object.prototype.hasOwnProperty.call(scripts, event) &&\n      !(event === 'start' && (await runScript.isServerPackage(path)))\n    ) {\n      if (this.npm.config.get('if-present')) {\n        return\n      }\n\n      const suggestions = require('../utils/did-you-mean.js')(pkg, event)\n      const wsArg = workspace && path !== this.npm.localPrefix\n        ? ` --workspace=${pkg._id || pkg.name}`\n        : ''\n      throw new Error([\n        `Missing script: \"${event}\"${suggestions}`,\n        '',\n        'To see a list of scripts, run:',\n        `  npm run${wsArg}`,\n      ].join('\\n'))\n    }\n\n    // positional args only added to the main event, not pre/post\n    const events = [[event, args]]\n    if (!this.npm.config.get('ignore-scripts')) {\n      if (scripts[`pre${event}`]) {\n        events.unshift([`pre${event}`, []])\n      }\n\n      if (scripts[`post${event}`]) {\n        events.push([`post${event}`, []])\n      }\n    }","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/run.js#L97-L133","documentation":"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.","triggerScenarios":"Running `npm run <event>` where `scripts[event]` is absent and not (`event === 'start'` and `runScript.isServerPackage(path)` is true), with `--if-present` unset.","commonSituations":"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.","solutions":["Run `npm run` with no args to list available scripts and confirm the exact name.","Add the missing script to package.json `scripts` (e.g. `\"build\": \"...\"`).","Use `--if-present` (`npm run build --if-present`) for optional scripts in shared tooling.","Check you are in the correct workspace: `--workspace=<pkg>` or run from the right directory."],"exampleFix":"// before\nnpm run biuld\n// after\nnpm run build   // or add \"biuld\" to scripts","handlingStrategy":"validation","validationCode":"function scriptExists(pkg, name) {\n  return Object.prototype.hasOwnProperty.call(pkg.scripts || {}, name)\n}\n// wrapper:\nif (!scriptExists(pkg, 'build')) {\n  console.warn('No build script; skipping')\n} else {\n  run('npm run build')\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runNpm(['run', name])\n} catch (e) {\n  if (/Missing script/.test(e.message)) { /* optional script, ignore */ return }\n  throw e\n}","preventionTips":["Use `npm run <script> --if-present` for optional scripts in shared tooling.","In monorepos, confirm the script exists in each workspace before invoking.","Run `npm run` (no args) to list scripts when debugging."],"tags":["run-script","package-json","npm-cli","argument-validation"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}