Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm start says the script is missing

Errornpm ERR! Missing script: "start"

Short answer

npm start runs the start script from the nearest package.json. The error means that file has no start entry and no server.js in its root for npm to fall back on. Add the script, run the one the project really uses (npm run lists them), or move to the right folder or workspace.

  • Applies to npm 10 and 11, Node.js 22 and 24, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print which package.json npm is using and the scripts it lists. If the folder is not the one you expected, that is the cause; if it is, the list shows what the project calls its start command.

    npm prefix
    npm run
  2. 2Match what you see, then jump to its fix

    1. 1npm run lists no start entry, and the project root has no file named server.jspackage.json has no start script and there is no server.jsFix
    2. 2npm run shows scripts like dev, serve or watch but no startThe project uses a different script name such as dev or serveFix
    3. 3npm prefix prints a folder that is not your app, such as a parent folder or a monorepo rootnpm picked up a different package.json than the one you meantFix
    4. 4The root package.json has a workspaces field and the start script is in packages/<name>/package.jsonThe script lives in a workspace, not in the root packageFix

What does the error look like?

  • npm ERR! Missing script: "start"
  • npm error Missing script: "start"
  • npm error To see a list of scripts, run:

Cause 1 of 4

package.json has no start script and there is no server.js

1Check

npm only invents a start command in one case: when a file called server.js sits in the package root, start defaults to node server.js. Without that file the script must be written down.

ls server.js
npm run

2Fix

Add a start script that runs your real entry file. If your entry is already server.js you can also just leave it out.

{
  "scripts": {
    "start": "node index.js"
  }
}

3Verify

Run it; the app should boot instead of printing the error.

npm start

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 4

The project uses a different script name such as dev or serve

1Check

With no argument, npm run prints every script the package defines. Frameworks often name the development command dev, and the production command only exists after a build.

npm run

2Fix

Run the script that exists. If you want npm start to work too (many hosts call it), point start at the same command.

npm run dev

# package.json, if hosting expects npm start
"scripts": { "start": "vite preview" }

3Verify

npm start now runs the chosen command.

npm start

Confirmed by docs.npmjs.com

Did this fix it?

Cause 3 of 4

npm picked up a different package.json than the one you meant

1Check

npm prefix prints the closest parent directory containing a package.json or node_modules. Inside a subfolder with no package.json of its own, npm uses the parent's, and that one may have no start script.

pwd
npm prefix

2Fix

Change into the folder whose package.json holds the script, then run it there.

cd path/to/the/app
npm start

3Verify

npm prefix now prints the app folder, and npm start runs.

npm prefix

Confirmed by docs.npmjs.com

Did this fix it?

Cause 4 of 4

The script lives in a workspace, not in the root package

1Check

In a workspaces monorepo the root usually has no start script of its own. Ask npm to run the script inside a named workspace instead.

grep -n workspaces package.json

2Fix

Target the workspace by name, or run the script in every workspace and skip the ones without it.

npm run start --workspace=api

# every workspace that has a start script
npm run start --workspaces --if-present

3Verify

The named workspace starts.

npm run start --workspace=api

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Keep a start script in every deployable package.json; hosts and containers call npm start by convention.
  • Run npm commands from the package folder, and check npm prefix when a command behaves oddly in a monorepo.
  • In CI, use npm run <name> --if-present for optional steps so a missing script does not fail the build by accident.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.