2 years ago

#66612

test-img

user17712685

Exported Variable Is Undefined

context:

  • object named multiVerse that I need to access in another file that isn't server.js (main file)

  • using module.exports={multiVerse} in server.js

  • requiring the main file using const {multiVerse} = require('./server.js');

  • when using function to arrange object (made in the same file I require main, calling its class as module on server.js) it tells me multiVerse is undefined

  • when requiring the class into server.js to use arrangeBodies() I am doing const NBody = require('./nbody') const nbody = new NBody(); before the multiVerse object is initialized

questions:

Am I exporting it correctly? Why am I getting undefined?

javascript

node.js

export

undefined

module.exports

0 Answers

Your Answer

Accepted video resources