【问题标题】:Nodejs Error: spawn git ENOENT when using simple-git to clone repoNodejs 错误:使用 simple-git 克隆 repo 时产生 git ENOENT
【发布时间】:2017-10-18 02:04:02
【问题描述】:

我正在构建一个应用程序来克隆一个 repo,解析 repo 中的 xml 文件并显示信息。我正在使用 simple-git npm 模块。我在我的本地系统和开发测试服务器上都有这个工作。我正在尝试将其部署到集成服务器,这是我得到的错误。我看到的一些东西说这是因为我试图克隆到的目录不存在,但它肯定存在。

这是我编写的代码,用于克隆 repo(如果它不存在)或拉取最新更改。这是一个类的方法。 this.path 是将 repo 克隆到的目录的路径。 this.repoRoot 是本地系统上 repo 根目录的路径。 this.remote 是遥控器的 url。

  /**
   * 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();
            });
          }
        })
      })
    })
  }

提前感谢您的帮助!

【问题讨论】:

    标签: node.js git npm


    【解决方案1】:

    事实证明,问题与运行服务器的帐户的权限有关。该帐户无权写入它尝试写入的目录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-08
      • 1970-01-01
      • 2022-11-02
      • 2021-04-11
      • 2013-08-07
      相关资源
      最近更新 更多