Home > Software design >  I can't find the right pathname
I can't find the right pathname

Time:10-10

I'm sorry for such an easy question.

In my articles.js file I want to include the find.js file. I just can't get the pathname right and I feel I have tried every possibility and I can't find the solution online. Could someone please help me?

Here is a picture of my folder

articles.js

const express = require("express");
const _ = require('lodash');
const router = express.Router();
const mongoose=require("mongoose");
const find = require("./config/functions/find.js")               //This one

CodePudding user response:

You need to go up a directory, like this:

const find = require("../config/functions/find.js");

CodePudding user response:

When you do local imports, you need to use the relative path. In your case, articles.js is inside of routes, so you should go one level up (..), and then navigate through config -> functions (/config/functions):

const find = require('../config/functions/find')
  • Related