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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay