Skip to content

Commit

Permalink
fix: closes #11173, clear require cache if wrong dependency is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Jan 18, 2023
1 parent 48c9f44 commit 747cb1f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ try {
if (!semver.satisfies(version, defaultPackage.dependencies[packageName])) {
const e = new TypeError(`Incorrect dependency version: ${packageName}`);
e.code = 'DEP_WRONG_VERSION';
// delete the module from require cache so it doesn't break rest of the upgrade
// https://github.com/NodeBB/NodeBB/issues/11173
const resolvedModule = require.resolve(packageName);
if (require.cache[resolvedModule]) {
delete require.cache[resolvedModule];
}
throw e;
}
};
Expand Down

0 comments on commit 747cb1f

Please sign in to comment.