- Creation of a simple node js application
- Installation and connection with DB
- Basic Commands used for the installtion
- Starting the application
To install a basic simple app for node firstly need to check the node version on the system
If node is not installed check the following documents for the node installation
After the start the application development
Once Node.js is installed, follow these steps to create the Node.js application:
Created a new directory for the project and navigate into it using the terminal or command prompt:
mkdir simple-nodejs-app
cd simple-nodejs-app
Initialize a new Node.js project by running the following command and following the prompts:
npm init
Open image-20240422-070338.png
This command will created a package.json file which will hold metadata of the project and its dependencies.
Install Express.js as a dependency for your project. Express.js is a minimalist web framework for Node.js:
npm install express
Create a file named app.js in your project directory.
app.js
// Import the Express.js module
const express = require('express');
// Create an Express application
const app = express();
// Define a route handler for the root URL '/'
app.get('/', (req, res) => {
res.send('Test Application!');
});
// Start the server and listen on port 3000
app.listen(3000, () => {
console.log('Server is running on http://localhost:3000');
});
Now run Node.js application by executing the app.js file using Node.js:
node app.js
Open your web browser and navigate to http://localhost:3000.
Open image-20240422-070317.png
Thank You