mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-04-01 10:13:38 -04:00
Fixed module update for modules like firebase-admin.js
This commit is contained in:
parent
c2eb1f2516
commit
22fc95926a
@ -4042,10 +4042,14 @@ function InstallModules(modules, args, func) {
|
|||||||
// Does the module need a specific version?
|
// Does the module need a specific version?
|
||||||
if (moduleVersion) {
|
if (moduleVersion) {
|
||||||
var versionMatch = false;
|
var versionMatch = false;
|
||||||
try { versionMatch = (require(`${moduleName}/package.json`).version == moduleVersion) } catch (ex) { }
|
var modulePath = null;
|
||||||
if (versionMatch == false) {
|
// This is the first way to test if a module is already installed.
|
||||||
const packageJson = JSON.parse(require('fs').readFileSync(require('path').join(__dirname, 'node_modules', moduleName, 'package.json'), 'utf8'));
|
try { versionMatch = (require(`${moduleName}/package.json`).version == moduleVersion) } catch (ex) {
|
||||||
if (packageJson.version != moduleVersion) { throw new Error(); }
|
if (ex.code == "ERR_PACKAGE_PATH_NOT_EXPORTED") { modulePath = ("" + ex).split(' ').at(-1); } else { throw new Error(); }
|
||||||
|
}
|
||||||
|
// If the module is not installed, but we get the ERR_PACKAGE_PATH_NOT_EXPORTED error, try a second way.
|
||||||
|
if ((versionMatch == false) && (modulePath != null)) {
|
||||||
|
if (JSON.parse(require('fs').readFileSync(modulePath, 'utf8')).version != moduleVersion) { throw new Error(); }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// For all other modules, do the check here.
|
// For all other modules, do the check here.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user