npm error Missing script: "start"
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · 11.19.0updated
- tool
- npm
- exit code
- 1
- versions
- npm 7 – 11
- os
- any
npm error Missing script: "start" means npm start or npm run start looked under "scripts" in the current package.json and found no start entry. npm only runs scripts defined there. Run npm run to list the scripts that exist, then either use the right name (often dev or serve) or add "start": "node server.js" to package.json.
Reproduce it
cat > package.json <<'EOF'
{ "name": "app", "version": "1.0.0", "scripts": { "build": "echo building" } }
EOF
npm run start 2>&1 | grep -v "complete log"
exit "${PIPESTATUS[0]}"Output · exit 1
npm error Missing script: "start" npm error npm error Did you mean one of these? npm error npm star # Mark your favorite packages npm error npm stars # View packages marked as favorites npm error npm error To see a list of scripts, run: npm error npm run
The Did you mean one of these? block lists npm commands or scripts with a similar name. Here it suggests npm star because no script is close to start.
Fix
List what exists, then add the missing script:
cat > package.json <<'EOF'
{ "name": "app", "version": "1.0.0", "scripts": { "build": "echo building" } }
EOF
npm run
npm pkg set scripts.start="node -e \"console.log('started')\""
npm run start --silentOutput
Scripts available in app@1.0.0 via `npm run`:
build
echo building
startednpm pkg set edits package.json without opening an editor. --silent hides the > app@1.0.0 start header line.
| Command | Looks for |
|---|---|
| npm start | scripts.start, or node server.js if server.js exists |
| npm test | scripts.test |
| npm run dev | scripts.dev (no fallback) |
| npm run | Lists all scripts of the current package.json |
In npm 6 and earlier the same error read npm ERR! missing script: start.
Sources
Related pages
errors · npmnpm error code ENOENT: Could not read package.jsonnpm fails with ENOENT Could not read package.json when run in a folder without package.json. cd into the project root, or create one with npm init -y.flags · npmnpm run script -- --flag: pass arguments to an npm scriptArguments after -- in npm run script -- --flag are passed to the script. Without the --, npm takes the flag as its own config and the script never sees it.errors · yarnyarn: error Command "dev" not found.Yarn 1 prints error Command "dev" not found when package.json has no such script and no binary has that name. Yarn 4 says Couldn't find a script named "dev".errors · bunbun run: error: Script not found "dev"bun run dev fails with Script not found "dev" when package.json has no dev script and no file of that name exists. Check scripts, folder and workspace.