执行 gitbook-install 报 spawn npm ENOENT 错误
原因:在windows下npm的执行命令不同1
将 gitbook-install/lib/util.js 文件中第53行代码修改如下
installPlugins() {
if(plugins === null) throw new Error('Error: no plugins');
if(args === null) throw new Error('Error: no npm arguments');
- cp.execFile('npm', args, (err, stdout) => {
+ cp.execFile(process.platform === 'win32' ? 'npm.cmd' : 'npm', args, (err, stdout) => {
if(err) {
throw(err);
} else {
log();
log(stdout);
process.exit();
}
});
return this;
},
将 gitbook-install/lib/util.js 文件中第53行代码修改如下
installPlugins() { if(plugins === null) throw new Error('Error: no plugins'); if(args === null) throw new Error('Error: no npm arguments'); - cp.execFile('npm', args, (err, stdout) => { + cp.execFile(process.platform === 'win32' ? 'npm.cmd' : 'npm', args, (err, stdout) => { if(err) { throw(err); } else { log(); log(stdout); process.exit(); } }); return this; },Footnotes
spawn npm ENOENT解决方法 ↩