javascript - How to reference files belonging to a module? -
i making module need use files, local module.
the path module can vary, depending on level of nesting , depending on whether if installed globally or locally.
how reference modules local files within module?
i found best solution:
for javascript libraries:
if javascript want include, can add relative path require call:
require('my-module/lib/other-script.js'); for other files open:
use module.filename obtain absolute path current file. remove file name , add relative path name it:
filename = module.filename.substring(0,module.filename.lastindexof("/"))+"/my/local/file.txt";
Comments
Post a Comment