Jul 14, 2024
express-js-tutorialcd express-js-tutorialnpm init -ynpm i expresscode .nodemon locally:
nodemon runs locally even if not installed globallysrc folderindex.js in srcpackage.json with scripts:
"scripts": {
"start": "node src/index.js",
"start:dev": "nodemon src/index.js"
}
nodemon:
Import Express:
const express = require('express');
Create an Express app instance:
const app = express();
Set the port:
const port = 3001;
Start the server:
app.listen(port, () => {
console.log(`Running express server on port ${port}`);
});
Running the Application:
npm start or npm run start:devhttp://localhost:3001Issue: "Cannot GET /"