FIXED ERROR : npm ERR! missing script: start in Node.js application

In this article we will learn how to fix npm err missing script start err! in nodejs application.

This error usually shows up when we run the command npm start to start our development server in nodejs.

npm ERR! missing script: start

Cause of the missing script start error

This error occurs when we run the command npm start because we have not define start inside the scripts object in the package.json file.

Fix npm ERR! missing script: start error

To resolve this error in our node application, we just have to define start in the scripts object in the package.jsonfile.

So first identify the root JavaScript file in your application. It can be main.js, app.js or server.js in your application.

Then open your package.json file and find the scripts section.

A default package.json file looks like this,

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1"

Now add the start script the scripts section after test.

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "start": "node index.js"

Replace the index.js by the root file name of your node application. In my case the root file is index.js.

Alternate way, if you don't want to edit the package.json of your node application, you can just run the main file directly by

node index.js

Related Topics:

Npm WARN Package.Json: No Repository Field

Resolve - Node Unexpected Token Import Error

Resolve Npm Cannot Find Module Error In Nodejs

(Resolved) Cannot Use Import Statement Outside A Module Error

💾 Recommended Articles