Я пытаюсь создать интерфейс командной строки, который автоматически клонирует созданный мной шаблон vuex-store-starter. Во время установки отображается ошибка, основанная на ошибке: spawn npm ENOENT
Любая помощь будет приветствоваться.
#! /usr/bin/env node
const {spawn} = require('child_process');
const name = process.argv[2];
if (!name || name.match(/[<>:"\/\\|?*\x00-\x1F]/)) {
return console.log(`
Invalid directory name.
Usage: <vuex-store-starter-cli> <repo-name>
`);
}
const URL = 'https://github.com/ChrisMichaelPerezSantiago/vuex-store-starter.git';
f('git', ['clone', URL, name])
.then(() => {
return f('rm', ['-rf', `${name}/.git`]);
}).then(() => {
console.log('Installing dependencies...');
return f('npm', ['install'], {
cwd: process.cwd() + '/' + name
});
}).then(() => {
console.log('Done! ?');
console.log('');
console.log('cd', name);
console.log('npm run start');
console.log('?For more information check the package.json')
});
function f(command, args, options = undefined) {
const spawned = spawn(command, args, options);
return new Promise((resolve) => {
spawned.stdout.on('data', (data) => {
console.log(data.toString());
});
spawned.stderr.on('data', (data) => {
console.error(data.toString());
});
spawned.on('close', () => {
resolve();
});
});
}
Вывод ошибки, который у меня есть
Cloning into 'vuex-store-starter-cli'...
Installing dependencies...
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn npm ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)