When main.js loads a.js, then a.js in turn loads b.js. At that point, b.js tries to load a.js. In order to prevent an infinite loop, an unfinished copy of the a.js exports object is returned to the b.js module. b.js then finishes loading, and itsexports object is provided to the a.js module.
By the time main.js has loaded both modules, they're both finished. The output of this program would thus be:
https://nodejs.org/api/all.html#all_cycles
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
http://blog.gaoqixhb.com/p/5594aae169112b794b3f0c16
看看这个会不会对你有帮助