1

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?

  • `require('./folder/hello')` for a folder in the current directory, `require('../folder/hello')` in a higher-level directory. See https://stackoverflow.com/questions/42163049/node-js-require-from-parent-folder. – code Feb 01 '22 at 04:22

0 Answers0