简体   繁体   中英

Nodejs Error: spawn git ENOENT when using simple-git to clone repo

I am building an app that clones a repo, parses xml files in the repo and displays the information. I am using the simple-git npm module. I have this working on my local system, and on the dev test server. I am trying to deploy it to an integration server and this is the error I get. Some of the stuff I have seen says it is because the directory I'm attempting to clone to doesn't exist, but it most definitely does.

从控制台输出中截取

Here is the code I wrote to either clone the repo if it doesn't exists or pull pull the latest changes. This is a method of a class. this.path is the path to the directory the repo will be cloned to. this.repoRoot is the path to the root of the repo on the local system. this.remote is the url for the remote.

  /** * gets the latest version of the remote repo and specified branch by either using clone or pull * @return {Promise<void>} */ getLatest() { return new Promise((resolve, reject) => { this.checkForDir(this.path).then((parentDirExists) => { if (!parentDirExists) { fs.mkdirSync(this.path); } }).then(() => { this.checkForDir(this.repoRoot).then((repoExistsLocally) => { if (!repoExistsLocally) { git(this.path).clone(this.remote).then((cloneResult) => { git(this.repoRoot).checkout(this.branch).then(() => { resolve(); }); }); } else { git(this.repoRoot).pull().then((pullResult) => { resolve(); }); } }) }) }) } 

Thanks in advance for any help!

As it turns out, the problem was related to permissions the account the server was running on. The account did not have permissions to write to the directory it was attempting to write to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM