In Node.js, How can I access exported module in Index.js?

I have searched in stackoverflow and it seems there isn’t any use case like mine.
I have a structure folders like this in functions directory:


I added some codes to be used by other functions like this in index.js:

const admin = require("firebase-admin");
const config = JSON.parse(process.env.FIREBASE_CONFIG);

const highLevel = {
  timeoutSeconds: 300,
  memory: "2GB",

const secretLevel = {
  timeoutSeconds: 120,
  memory: "1GB",
  secret: [process.env.SERVER_BACKEND],

const lowLevel = {
  timeoutSeconds: 120,
  memory: "512MB",

module.exports = lowLevel, highLevel, secretLevel;

I created a file in a folder structure like this:


How can I access the variable of lowLevel from publisher.js as I tried using this:

const lowLevel = require("../index");

and I can’t get any of reference to index.js. Is there a way to access file index.js from the root folder? Thank you very much for any tips and trick.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

From this file:


If you want access to this file:


You would do that with:

 const lowLevel = require("../../../index.js");

The first .. moves up to the functions/admin/features directory.

The second .. moves up to the functions/admin directory.

The third .. moves up to the functions directory where you say that index.js is.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x