How to export and import functions from one folder to another using modules.exports from express?

Viewed 263

I'm trying to export a function from one folder to another by using module.exports, I can only do it from one archive to another in this wey:

//archive1.js

module.exports.nameOfTheFunction = nameOfTheFunction

and then importing in the other archive this way:

//archive2.js

const something = require('./archive1')

let nameOfTheFunction = archive1.nameOfTheFunction

How should I import a function from one folder to another?

0 Answers
Related