It might be a simple but unable to crack it. started learning node.js. i want to use password-manager.js file in test.js. how can i do this.
**
My Directory structure:-
root
-home
- node-basics
- node-password
- password-manager.js
-node-mongo-connection
-test.js
**
//In password-manager.js
module.exports = function(){
//code.......
}
//I tried to module.exports
// test.js
var pm = require('/../../password-manager.js');
//but not sure doing it correctly or its a correct method or not.
Your relative path to password-manager.js
is wrong.
Use this:
var pm = require('../node-password/password-manager');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.