NodeJS requires a module that is inside another module

How do I get a module that is dependent on another module? For instance:

Project/foo.js Project/nodule_modules/MyModule/node_modules/AnotherModule //dependencie of MyModule 

How can I require "AnotherModule" from the foo.js file?

+4
source share
1 answer

Use in foo.js module:

 var that = require('./node_modules/MyModule/node_modules/AnotherModule'); 

See http://nodejs.org/api/modules.html#modules_file_modules

+3
source

Source: https://habr.com/ru/post/1446887/


All Articles