bugfix : spawing npm install of module not working on Windows & node < v6.x.x (issue #2223)

This commit is contained in:
Valentin 'ThisIsMac' M 2016-07-06 16:14:32 +02:00
parent 3b75c46cdb
commit 30d90b7d5b

View File

@ -104,26 +104,27 @@ function installModule(CLI, module_name, cb) {
*/
//UX.processing.start('Downloading module');
Common.printOut(cst.PREFIX_MSG_MOD + 'Calling ' + chalk.bold.red('[NPM]') + ' registry...');
var install_instance;
install_instance = spawn('npm', [
install_instance = spawn(cst.IS_WINDOWS ? 'npm.cmd' : 'npm', [
'install', module_name, '--prefix', cst.PM2_ROOT_PATH, '--loglevel=error'
],{
stdio : 'inherit',
async : true,
env: process.env,
shell : cst.IS_WINDOWS
});
install_instance.on('close', finalize);
install_instance.on('error', function ( err ) {
// handle just to not crash
});
function finalize(code) {
// if (code != 0) {
// Common.printError(cst.PREFIX_MSG_MOD_ERR + 'Installation failed');
// console.log(err, code, out);
// return cb(new Error(err));
// }
if (code != 0) {
return cb(new Error("Installation failed"));
}
Common.printOut(cst.PREFIX_MSG_MOD + 'Module downloaded');