. Advertisement .
..3..
. Advertisement .
..4..
Do you encounter the errors of NPM start not working in Javascript? No worry, we are here to help. The guidelines below will provide extensive reasons for such issues and solution tactics. Check them out!
What Is The Error of NPM Start Not Working?
This command runs your start command within the “package.json” file of your specific projects. And when your existing working directory does not have this file, the consol will send back no such files (or directory errors):
$ npm start
npm ERR! enoent ENOENT: no such file or directory, open '/package.json'
And when there is no start command in your “package.json” file (beneath the script property), NPM will operate “node.server.js” in its place.
Once you activate the “npm start” command, you might stumble upon an error message, which states that your start script is nowhere to be seen:
$ npm start
npm ERR! Missing script: "start"
Why does that happen? The start script does not receive any definition while the “package.json” file runs in your application. For most cases, that script may pop up like this:
{
"scripts": {
"start": "node app.js"
},
}
The script content may differ, but regardless, it should also stay within its property. Hence, if it is existent within your “package.json” file but still fails to run the scripts, it is time you inspect the console outputs. See no outputs at all? Then there are possibilities that the system set the ignore-scripts NPM configurations to ‘false’.
How to Fix This Error?
Let’s see what we can do to assess this issue. One plausible tactic is navigating to the “package.json” file to add start scripts. Once done, the “npm start” command will be ready for usage.
First of all, navigate to the “package.json” file. How to do that? Type “npm init” in the terminal. The system will take you through the procedure of “package.json” creations. It will ask about fundamental issues, such as names for the starting files and the projects.
Suppose you have a file “App.js”. So what you need to do is to type “App.js” to obtain the “entry point”. Choose the best one, then hit “Enter” to confirm the settings.
[package name: (mata) dev
[version: (1.0.0)
[description: App.js
[entry point: (.mongorc.js) App.js
[test command:
[git repository:
[keywords:
author:
license: (ISC)
About to write to /Users/mata/package.json:
{
"dependencies": {
"app-root-path": "^3.0.0"
},
"name": "dev",
"version": "1.0.0",
"description": "App.js",
"main": "App.js",
"devDependencies": {},
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author":"
"license": "ISC"
}
Is this OK? (yes) yes
Now, enter the file location to open it. The system will save your “package.json” file in your existing terminal directory. In this example, we are in our user directory (where “App.js” currently resides), and that’s why we can find our file here.
Next, insert start scripts in the “package.json” files within the “script” object. This strategy helps you run the “npm start” command.
{ "dependencies": {
"app-root-path": "^3.0.0"
},
"name": "dev",
"version": "1.0.0",
"description":"",
"main": "App.js",
"devDependencies": {},
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"start": "node App.js"
},
"author":"",
"license": "ISC"
}
For those who use Postman, this error message “postman: You need to enable JavaScript to run this app” might pop up. Refer to this guide for optimal solutions!
Conclusion
This article has instructed you on how to fix the errors of NPM start not working. Write to us if you still have questions, and we will try our best to help!
Leave a comment