Sangram Badi
Sangram Badi

Reputation: 4264

How to access a file from one another file in nodejs project

I have the below project structure. I am trying to access db.js inside CategoryController.js.

enter image description here

I have used the code below.

var db = require('./../routes/db');

when I'm trying to run the Node.js project using npm start it is showing the error below.

enter image description here

Upvotes: 1

Views: 58

Answers (1)

Lepanto
Lepanto

Reputation: 1413

Try below

var db = require('./../db.js');

as the db.js file is just out of controllers folder

Upvotes: 4

Related Questions