i would suggest sending a JSON string with the packages to a dataserver, and load it from there automatically on startup, i use this often for python and c++( i make my own package managers ) so they do not crash in glitch.
if your wondering how it works it is like this:
var db = new PKG_SERVER();
db.send([{pkg:'lodash', version:'*'}, {pkg:'node-gyp', version:'*'}, {pkg:'FLRM', version:'*.2'}])
db.on('load', (pkgs) => {
var exe = require('child_process').execSync;
var versions = pkgs.map(t => t.version);
var pd = pkgs.map(t => t.pkg);
for (let i = 0; i<pd.size; i++){
exe(`npm i ${pd[i]}@${versions[i]}`
}
});
module.exports = db.load;
this should output the installation of the following packages
lodash : *
node-gyp : *
FLRM : 1.0.2
if that doesnt work, after the exe variable is called, add the following line of code:
exe('rm -rf node_modules; declare -x env=null')//sets node-env status to false and resets modules
if you want to install it to the server, replace
exe(`npm i ${pd[i]}@${versions[i]}`
with:
exe(`pnpm install ${pd[i]}@${versions[i]}`
note: if you want to save it to a dataserver for your content of automatic package loading, just dm me XD
the execution to reinstall would be in a separate file which can be concluded by the module.exports at the end of the large blob of code at the top, and the code that would trigger the installation will be the following:
var blahblah = require('./data-serve.js');
blahblah();