Error:
# npm start
# my-app@1.0.0 start
# index.js
sh: index.js: command not found
If you are trying to start a nodeJs application using npm command and you get the above error, then below are some of the reasons for it.
Reasons for the error:
- You have not created the index.js file.
- You have placed the index.js file not in the root folder of your application.
- You have not added the start script inside package.json file.
- You have added the wrong valve for the start command.
Solution:
Below is an example of how a simple setup for your node application should look like.
package.json
{
"name": "my-app",
"version": "1.0.0",
"description": "Learning npm and node",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "code2care",
"license": "ISC",
"dependencies": {
}
}
index.js
console.log("Hello node.js")

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!