Sep 3, 2024
xampp-control.exe
and start Apache & MySQL.node -v
npm init -y
.
package.json
file.express
: Framework to start the server.mysql
: To connect Node.js with MySQL.dotenv
: To manage sensitive information.hbs
: For HTML templating.nodemon
: Automatically restarts server on changes.
npm install --save nodemon
sudo
for installation on macOS if errors arise.app.js
file in the project folder.const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('home page');
});
app.listen(5001, () => {
console.log('Server started on port 5001');
});
package.json
:
"scripts": {
"start": "nodemon app.js"
}
npm start
to run the server with nodemon for live reloads.localhost:5001
.