Skip to content
Latchkey

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 app

Common 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:e2e

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →