DEV Community

Cover image for Full Backend Project Setup And Structure in NodeJS Part - 1
SHaon
SHaon

Posted on

Full Backend Project Setup And Structure in NodeJS Part - 1

First of all setup backend project:

  1. Create a folder and open in any code editor like: VsCode

Open Terminal and run this code:

npm init -y
Enter fullscreen mode Exit fullscreen mode
  • Lets Setup Project Folder Structure and files

create importants folder like:

.
└── root/
    ├── public/
    │   └── temp
    ├── src/
    │   ├── app.js
    │   ├── index.js
    │   ├── constants.js
    │   ├── controllers/
    │   │   └── index.js
    │   ├── middlewares/
    │   │   └── index.js
    │   ├── routes/
    │   │   └── index.js
    │   ├── utils/
    │   │   └── index.js
    │   ├── db/
    │   │   └── index.js
    │   └── models/
    │       └── index.js
    ├── .env
    ├── .env.sample
    ├── .gitignore
    ├── .prettierrc
    └── .pretterignore
Enter fullscreen mode Exit fullscreen mode

After this you need to install some NPM packages* like
Nodemon and Pretttier

Open your terminal from root directory and run the following code:

npm i -D nodemon prettier
Enter fullscreen mode Exit fullscreen mode

after successfully installed goto package.json file and update it with the following code snippet:

{
  "name": "node",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "dev": "nodemon src/index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "nodemon": "^3.1.0",
    "prettier": "^3.2.5"
  }
}

Enter fullscreen mode Exit fullscreen mode

then add your gitignore and prettier setup

Read part -2

Top comments (0)