Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
160
rated 0 times [  161] [ 1]  / answers: 1 / hits: 46538  / 7 Years ago, fri, february 10, 2017, 12:00:00

I have the following structure:



-- node_modules
-- websites
---- common
------- config.js
---- testing
------- test.js


Inside config I have some variables set, which are being exported using module.export.



I am trying to retrieve those variables when running node test.js from config.js using the following codes:



var configData = require('./common/config.js')
var configData = require('../common/config.js')


None of them work. What can I do to retrieve the data from the other folder?


More From » node.js

 Answers
121
var configData = require('./../common/config.js');



  1. ./ is testing/


  2. ./../ is websites/


  3. ./../common/ is websites/common/


  4. ./../common/config.js is websites/common/config.js



[#58985] Wednesday, February 8, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
taliac

Total Points: 84
Total Questions: 114
Total Answers: 114

Location: Morocco
Member since Fri, May 22, 2020
4 Years ago
;