-
-
Save smugen/4286736 to your computer and use it in GitHub Desktop.
Node.js require cache test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var b = require('./b') | |
,c = require('./c'); | |
console.log(__filename, ":", c.msg); | |
console.log(__filename, ":", c === b.c); | |
console.log(__filename, ":", "delete require cache, and require c again"); | |
delete require.cache[require.resolve('./c')]; | |
c = require('./c'); | |
console.log(__filename, ":", c.msg); | |
console.log(__filename, ":", c === b.c); | |
console.log(__filename, ":", b.c.msg); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(__filename, "enter"); | |
var c = require('./c'); | |
console.log(__filename, ":", c.msg); | |
c.msg = "I say B!"; | |
exports.c = c; | |
console.log(__filename, "exit"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(__filename, "enter"); | |
exports.msg = "I am C."; | |
console.log(__filename, "exit"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
execute
output