Make clean file import and remove ../../ in node js Application

 In this section we will learn how to use modular apprach to ../../ remove from import file in node js

Follow below steps ;-

Install module-alias from below command ->

npm install module-alias

and in you package.json add this section -> 

"_moduleAliases": {

  "@src": "src",

  "@prisma": "src/prisma",

  "@modules": "src/modules"

}


after in your src/server.js add this line in top ->import "module-alias/register";


and now instead of this -> import prisma from "../../prisma/client.js"; you can use 

import prisma from "@prisma/client.js";

Comments

Popular posts from this blog

Basics Of PHP

Creating App.js for Node Application

WordPress Full Guide For Developer