![]() |
VOOZH | about |
Visual Studio Code (VS Code) is a powerful and user-friendly code editor that is widely used for web development. It comes with features like syntax highlighting, code suggestions, and extensions that make coding easier. In this article, we'll show you how to quickly create and run a Node.js project using VS Code.
Create an empty folder and move it into that folder from your VS Code editor, use the following command.
mkdir demo
cd demo
code .👁 Terminal Code to Create a New Project DirectoryInstall the modules using the following command.
npm install express
npm install nodemon1. Open the package.json file (it should be automatically created after running npm init or installing any modules).
2. Add the following commands under the scripts section to run the application:
"scripts": {
"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": "^5.1.0",
"nodemon": "^3.1.9"
}
}The following is the project structure
👁 Project Structure of Node JsGo back to your terminal and run the following command to start the server with nodemon:
npm run devOutput:
👁 Ternimal OutputNow go to http://localhost:5000/ in your browser, you will see the following output:
👁 Browser Output