Closed
Description
We have this piece of code in our CLI tool:
function getVersion() {
return require('../../package.json').version;
}
A customer experienced an issue where he re-installed a new version of our software via npm, and when he ran it, he saw that he was getting the package version from the older installation.
I can verify from his terminal log that the newer package was installed.
If it makes any difference, it is a globally installed tool.
I can have a workaround by manually deleting it from the cache.
function getVersion() {
//fixing Node bug
var name = require.resolve('../../package.json');
delete require.cache[name];
return require('../../package.json').version;
}
Is this a bug, or an expected behavior?
This was experienced in Node v4.1.2.
I don't know if it affects other versions.