mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Fix package installs and set node 20 for docker (#5692)
* fix install packages and set docker to node 20 Signed-off-by: si458 <simonsmith5521@gmail.com> * missed a few no-package-lock and no-save Signed-off-by: si458 <simonsmith5521@gmail.com> * use --save-exact and only install missing modules Signed-off-by: si458 <simonsmith5521@gmail.com> --------- Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
7c2eea68b6
commit
ef6fd23a4f
6 changed files with 1713 additions and 13 deletions
|
@ -471,7 +471,8 @@ function CreateMeshCentralServer(config, args) {
|
|||
const npmproxy = ((typeof obj.args.npmproxy == 'string') ? (' --proxy ' + obj.args.npmproxy) : '');
|
||||
const env = Object.assign({}, process.env); // Shallow clone
|
||||
if (typeof obj.args.npmproxy == 'string') { env['HTTP_PROXY'] = env['HTTPS_PROXY'] = env['http_proxy'] = env['https_proxy'] = obj.args.npmproxy; }
|
||||
const xxprocess = child_process.exec(npmpath + ' install --no-audit --no-package-lock meshcentral' + version + npmproxy, { maxBuffer: Infinity, cwd: obj.parentpath, env: env }, function (error, stdout, stderr) {
|
||||
// always use --save-exact - https://stackoverflow.com/a/64507176/1210734
|
||||
const xxprocess = child_process.exec(npmpath + ' install --save-exact --no-audit meshcentral' + version + npmproxy, { maxBuffer: Infinity, cwd: obj.parentpath, env: env }, function (error, stdout, stderr) {
|
||||
if ((error != null) && (error != '')) { console.log('Update failed: ' + error); }
|
||||
});
|
||||
xxprocess.data = '';
|
||||
|
@ -3857,7 +3858,7 @@ function InstallModules(modules, args, func) {
|
|||
}
|
||||
}
|
||||
|
||||
if (missingModules.length > 0) { if (args.debug) { console.log('Missing Modules: ' + missingModules.join(', ')); } InstallModuleEx(modules, args, func); } else { func(); }
|
||||
if (missingModules.length > 0) { if (args.debug) { console.log('Missing Modules: ' + missingModules.join(', ')); } InstallModuleEx(missingModules, args, func); } else { func(); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3865,23 +3866,23 @@ function InstallModules(modules, args, func) {
|
|||
// this is to make sure NPM gives us exactly what we need. Also, we install the meshcentral with current version, so that NPM does not update it - which it will do if obmitted.
|
||||
function InstallModuleEx(modulenames, args, func) {
|
||||
var names = modulenames.join(' ');
|
||||
console.log('Installing modules...');
|
||||
console.log('Installing modules', modulenames);
|
||||
const child_process = require('child_process');
|
||||
var parentpath = __dirname;
|
||||
function getCurrentVersion() { try { return JSON.parse(require('fs').readFileSync(require('path').join(__dirname, 'package.json'), 'utf8')).version; } catch (ex) { } return null; } // Fetch server version
|
||||
const meshCentralVersion = getCurrentVersion();
|
||||
if ((meshCentralVersion != null) && (args.dev == null)) { names = 'meshcentral@' + getCurrentVersion() + ' ' + names; }
|
||||
//const meshCentralVersion = getCurrentVersion();
|
||||
//if ((meshCentralVersion != null) && (args.dev == null)) { names = 'meshcentral@' + getCurrentVersion() + ' ' + names; }
|
||||
|
||||
// Get the working directory
|
||||
if ((__dirname.endsWith('/node_modules/meshcentral')) || (__dirname.endsWith('\\node_modules\\meshcentral')) || (__dirname.endsWith('/node_modules/meshcentral/')) || (__dirname.endsWith('\\node_modules\\meshcentral\\'))) { parentpath = require('path').join(__dirname, '../..'); }
|
||||
|
||||
if (args.debug) { console.log('NPM Command Line: ' + npmpath + ` install --no-audit --no-package-lock --omit=optional --no-save --no-fund ${names}`); }
|
||||
|
||||
child_process.exec(npmpath + ` install --no-audit --no-package-lock --no-optional --omit=optional --no-save ${names}`, { maxBuffer: 512000, timeout: 300000, cwd: parentpath }, function (error, stdout, stderr) {
|
||||
if (args.debug) { console.log('NPM Command Line: ' + npmpath + ` install --save-exact --no-audit --omit=optional --no-fund ${names}`); }
|
||||
// always use --save-exact - https://stackoverflow.com/a/64507176/1210734
|
||||
child_process.exec(npmpath + ` install --save-exact --no-audit --no-optional --omit=optional ${names}`, { maxBuffer: 512000, timeout: 300000, cwd: parentpath }, function (error, stdout, stderr) {
|
||||
if ((error != null) && (error != '')) {
|
||||
var mcpath = __dirname;
|
||||
if (mcpath.endsWith('\\node_modules\\meshcentral') || mcpath.endsWith('/node_modules/meshcentral')) { mcpath = require('path').join(mcpath, '..', '..'); }
|
||||
console.log('ERROR: Unable to install required modules. MeshCentral may not have access to npm, or npm may not have suffisent rights to load the new module. To manualy install this module try:\r\n\r\n cd "' + mcpath + '"\r\n npm install --no-audit --no-package-lock --no-optional --omit=optional --no-save ' + names + '\r\n node node_modules' + ((require('os').platform() == 'win32') ? '\\' : '/') + 'meshcentral');
|
||||
console.log('ERROR: Unable to install required modules. MeshCentral may not have access to npm, or npm may not have suffisent rights to load the new module. To manualy install this module try:\r\n\r\n cd "' + mcpath + '"\r\n npm install --no-audit --no-optional --omit=optional ' + names + '\r\n node node_modules' + ((require('os').platform() == 'win32') ? '\\' : '/') + 'meshcentral');
|
||||
process.exit();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue