Steps to create Folder Structure
Step 1: Open the terminal and go to the path where you want to create the project and create a folder with your project name.
mkdir folder_name
Step 2: Run the command npm init to initialized the node project. This will create the package.json file
npm init
Step 3: Install the dependencies like express, nodemon etc. This will create package-lock.json file and node_modules folder.
npm i express nodemon
Step 4: Run the command git-init to initialized the git in the project. This will add .gitignore file.
git init
Step 5: Create a file named Readme.md which will contain all the info of the project.
touch Readme.md
Step 6: Create a file with extension .env which will contain the sensitive information and credentials of the project.
touch process.env
Step 7: Create a file named app.js or index.js will will be the end point to run the application.
touch app.js
Step 8: Create folder like public (contains static files and resources) and src (contains folders like controllers, models routes, views).
mkdir src
Folder structure for a Node JS project
Organizing a Node JS project with well planned folder structure is crucial for readability, scalability, and maintainability. A clear structure helps in managing code, configurations, modules, and other assets effectively. In this article, we are going to learn the folder structure of the Node JS project. We are going to learn all the directories present in the folder structure and files present in the Node JS project.
Contact Us