npm start: Usage & Common CI Errors
Start your application via the start script.
npm start runs the "start" script from package.json. If no start script is defined, npm falls back to running node server.js.
What it does
Runs the start script (with prestart/poststart hooks). With no start script and a server.js present, it defaults to node server.js. It is a long-running command, so it does not exit on its own.
Common usage
Terminal
npm start # run the start script
npm start -- --port 4000 # forward args to the appCommon CI error: job hangs on npm start
A CI step that runs npm start to boot a server never returns, because npm start blocks forever and the job times out. In CI, start the server in the background and wait for it to be ready before running tests against it, rather than running npm start as a foreground step.
.github/workflows/ci.yml
npm start & # background the server
npx wait-on http://localhost:3000 # block until it responds
npm run test:e2eRelated guides
npm "Missing script" - Fix "npm run" Cannot Find the Script in CIFix npm "Missing script: build" in CI - npm run cannot find the named script because it is absent, misspelled…
npm run: Usage, Options & Common CI ErrorsHow npm run executes package.json scripts, passing args with --, and the "missing script" error that fails CI…
npm ELIFECYCLE / Exit Status Errors - Diagnose Failing npm ScriptsUnderstand npm ELIFECYCLE and non-zero "Exit status" errors in CI - they mean your script failed. How to find…