npm ERR! Missing script: "start" (How to Fix!)

December 8, 2022

npm ERR! Missing script:

This guide is part of the “Common JavaScript Errors” series. It’s focused entirely on providing quick and easy solutions for JavaScript-related problems.


The "npm ERR! Missing script: 'start'" error is a common error that occurs when you try to run the npm start command on a Node.js project, but the project does not have a start script defined in its package.json file.

Here are the main reasons for this error to come up:

  • The package.json file is missing or corrupt.
  • The start script is not defined in the package.json file.
  • The start script is defined in the package.json file, but it is not a valid script.

In Node.js, the package.json file is a manifest file that contains metadata about your project, such as its name, version, dependencies, and scripts. The scripts section of the package.json file defines command-line scripts that you can run using the npm command.

For example, you might define a start script in your package.json file that runs a development server for your project, like this:

package.json

{
  "name": "my-project",
  "version": "1.0.0",
  "scripts": {
    "start": "node server.js"
  }
}

In this package.json file, the start script is defined as node server.js, which means that running the npm start command will run the server.js file using the node command.

If you try to run the npm start command on a project that does not have a start script defined in its package.json file, you will get the "npm ERR! Missing script: 'start'" error. This is because the npm command is unable to find the start script, and it therefore cannot run it.

Here is an example of running the npm start command to execute the start script defined in the package.json file:

$ npm start

> my-project@1.0.0 start /path/to/my-project
> node server.js

Server listening on port 3000