Suppose you have test.js, file.js and you have the following description in test.js:
//test.js
var hoge = true;
require('./file');
Is there any way to view hoge from file.js?
node.js
Resolved by changing var hoge=true;
to global.hoge=true;
.
However, it may not be a very recommended method.
This post was posted as a community wiki based on @user26654's comments.
© 2024 OneMinuteCode. All rights reserved.