ITADN

node does not propagate the module.paths to the require('module')

#25861Closedwyattbiker 创建于 2015-08-14
W
wyattbikercommented
I start my main.js application and push into module.paths the global module folder. When i require a 3rd party module (in this case cmod.js) that also requires a module which is in my globals module folder, it does not find the module and fails. Is there some way to force module.paths updated in main.js to be used also by the module cmod.js below: so for example: **mymain.js** ``` //global modules path module.paths.push('C:\Users\xuser\AppData\Roaming\npm'); // finds ws in global modules path. Works! wsmain=require('ws') // Now load a 3rd party module, which also requires('ws'); C = require('cmod.js'); ``` **cmod.js** ``` ws=require('ws'); // **fails to find global path** ```
关闭于 2023-04-22 1 条评论