Following are some simple steps in order to create a simple NodeJS project and running it in VS Code editor.
Step 1: Create an empty folder and move it into that folder from your VS Code editor, use the following command.
mkdir demo
cd demo
code .

Step 2: Now create a file app.js file in your folder as shown below.

Step 3: Installing Module: Install the modules using the following command.
npm install express
npm install nodemon
Step 4: Add these two commands which are important for running and dynamically running the code after changes made in your Node.js app respectively in package.json file.
"start": "node app.js",
"dev": "nodemon app.js"
Configuration of package.json File:
{
"name": "demo",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"dev": "nodemon app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"nodemon": "^2.0.12"
}
}
Step 5: Following will be our project structure:

Step 6: Write down the following code in app.js file.
Javascript
const express = require( 'express' );
const app = express();
app.get( '/' , (req, res) => {
res.send( 'A simple Node App is '
+ 'running on this server' )
res.end()
})
const PORT = process.env.PORT ||5000;
app.listen(PORT,console.log(
`Server started on port ${PORT}`));
|
Step 7: Run the application using the following command:
npm run dev
Output:

Step 8: Now go to http://localhost:5000/ in your browser, you will see the following output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!