node.js require from parent folder

前端 未结 2 1282
逝去的感伤
逝去的感伤 2020-12-23 21:26

I have the following structure:

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

Inside config I have

2条回答
  •  庸人自扰
    2020-12-23 22:11

    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

提交回复
热议问题