Skip to content

Instantly share code, notes, and snippets.

@GiladShoham
Last active September 15, 2022 19:41
Show Gist options
  • Select an option

  • Save GiladShoham/b8d29c2ffb39bf99ee1b5ccc92b3eb90 to your computer and use it in GitHub Desktop.

Select an option

Save GiladShoham/b8d29c2ffb39bf99ee1b5ccc92b3eb90 to your computer and use it in GitHub Desktop.
require cache issue
const fs = require('fs');
try {
require('my-package');
console.log('succuss require my-package');
} catch (err) {
console.log('failed require my-package');
}
fs.symlinkSync('pathToMyPackageInAnotherFolder', './node_modules/my-package', 'dir');
try {
require('my-package');
console.log('succuss require my-package');
} catch (err) {
console.log('failed require my-package');
}
@zkochan
Copy link

zkochan commented Sep 15, 2022

It is not related to symlinks. I updated the example to use real files.

And I have filed an issue in node.js: nodejs/node#44663

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment