Thomas Heck
Thomas Heck

Reputation: 15

I can't find the right pathname

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

Upvotes: 0

Views: 30

Answers (2)

P.Gracia
P.Gracia

Reputation: 274

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')

Upvotes: 0

habs
habs

Reputation: 121

You need to go up a directory, like this:

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

Upvotes: 1

Related Questions