Node can't find certain modules after synchronous install
问题 I've got a script that synchronously installs non-built-in modules at startup that looks like this const cp = require('child_process') function requireOrInstall (module) { try { require.resolve(module) } catch (e) { console.log(`Could not resolve "${module}"\nInstalling`) cp.execSync(`npm install ${module}`) console.log(`"${module}" has been installed`) } console.log(`Requiring "${module}"`) try { return require(module) } catch (e) { console.log(require.cache) console.log(e) } } const http =