24 lines
611 B
JavaScript
24 lines
611 B
JavaScript
var npm = require("npm");
|
|
var path = require("path");
|
|
npm.load({
|
|
loaded: false
|
|
}, function (err) {
|
|
|
|
let target = path.resolve("./testPackage");
|
|
let last = process.cwd();
|
|
process.chdir(target);
|
|
console.log('p',process.cwd());
|
|
|
|
// catch errors
|
|
npm.commands.install(['.'], function (er, data) {
|
|
// log the error or data
|
|
//data && console.log('install',data);
|
|
if(er){
|
|
console.error('err',er);
|
|
}
|
|
});
|
|
npm.on("log", function (message) {
|
|
// log the progress of the installation
|
|
//console.log('log',message);
|
|
});
|
|
}); |