To initialize
a Node.js project locally,
npm init -y
let firstName = "Harkirat Singh"
console.log(firstName)
node index.js
script
in package.json
"scripts": {
"start": "node index.js"
},
npm run start
In a Node.js application, npm start and npm run start are usually equivalent, but there are some nuances:
npm start
This is a shorthand command that executes the start script defined in your package.json file.
If there is a start script defined in the scripts section of package.json, npm start will run it.
If no start script is defined, npm start will default to running node server.js (if a server.js file exists in the root directory).
npm run start
This is a more explicit way to run any script defined in the scripts section of your package.json.