2015-11-03 74 views
2

我試圖啓動腳手架與自耕農自定義生成的應用程序時,一個混帳回購協議的時候,這就是我在install步了:處理錯誤事件,約曼自定義的生成嘗試運行命令

install: function() { 
    this.installDependencies(); 
    this.spawnCommand('npm', ['i', '--save' , 'express', 'mongodb', 'mongoose', 'lodash', 'bluebird', 'async', 'morgan']); 
    this.spawnCommand('git' ['init']); // Here fails 
    this.spawnCommand('git', ['add', '.']); 
    this.spawnCommand('git', ['commit', '-am', '"yo scaffolded app"']); 
    } 

試圖運行此我得到然而,當:

events.js:85 
     throw er; // Unhandled 'error' event 
      ^
TypeError: Bad argument 
    at TypeError (native) 
    at ChildProcess.spawn (child_process.js:1136:26) 
    at Object.exports.spawn (child_process.js:995:9) 
    at spawn (/storage/home/dev/generator-koala/node_modules/yeoman-generator/node_modules/cross-spawn/index.js:87:19) 
    at spawnCommand (/storage/home/dev/generator-koala/node_modules/yeoman-generator/lib/actions/spawn_command.js:17:10) 
    at module.exports.yeoman.generators.Base.extend.install (/storage/home/dev/generator-koala/generators/app/index.js:72:10) 
    at /storage/home/dev/generator-koala/node_modules/yeoman-generator/lib/base.js:421:16 
    at processImmediate [as _immediateCallback] (timers.js:367:17) 

我已經安裝的git,我應該怎麼解決這個問題?

+0

嘗試僅僅運行'git的init'減少範圍。 –

+0

我不明白你 – diegoaguilar

+0

你有很多命令被同時觸發,所以如果你只運行一個命令,你會確保沒有任何因副作用而失敗的命令。您需要減少問題的範圍才能正確調試它。 –

回答

0

您沒有使用回調,所以更改spawnCommandspawnCommandSync

install: function() { 
    this.installDependencies(); 
    this.spawnCommandSync('npm', ['i', '--save' , 'express', 'mongodb', 'mongoose', 'lodash', 'bluebird', 'async', 'morgan']); 
    this.spawnCommandSync('git' ['init']); 
    this.spawnCommandSync('git', ['add', '.']); 
    this.spawnCommandSync('git', ['commit', '-am', '"yo scaffolded app"']); 
    }