How to fix npm start command not working

Updated onbyAlan Morel
How to fix npm start command not working

Every Node project comes with a package.json file that contains all the information about your project, including the project's commands.

Without this file, you won't be able to run any commands, meaning when you try running npm start, you will get an error like this:

$ npm start npm ERR! enoent ENOENT: no such file or directory, open '/package.json'

In this post, we'll learn about how to fix this issue so you can run your project's commands.

Creating a package.json file

When you get the above error, it means that you don't have a package.json file in the directory that you tried running npm start in.

To create a package.json file, you can run this command:

npm init

This will create a package.json file in the current directory after you complete the inputs.

Creating a start script

By now you should have a package.json file, either created by you or by npm when you ran npm init.

Now you need to make sure there exists a script called start in your package.json file.

Make sure your package.json file looks like this:

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

If you don't have this, you will get this error when you try to run npm start:

npm ERR! Missing script: "start"

Otherwise, your command should run.

Disabling ignore-scripts

One final thing you might have to do is disable the ignore-scripts option in npm.

When this is enabled, it will ignore the scripts in your package.json file.

To disable it, run this command:

npm config set ignore-scripts false

Once you've set this to false and you have a valid script in your package.json file, you should be able to run the command.


In this post, we learned how to resolve the issue of not being able to run your project's start command.

Once you create a package.json file and a start script, you can run your project's commands, assuming you have disabled ignore-scripts.

Hopefully, this has been helpful to you. Happy coding!

To learn more about web development, founding a start-up, and bootstrapping a SaaS, follow me on X!
Copyright © 2017 - 2024 All rights reserved. Made with ❤ in NY.