【问题标题】:npm install can't resolve git repositories - certificate failurenpm install 无法解析 git 存储库 - 证书失败
【发布时间】:2014-02-21 09:14:04
【问题描述】:

我有一个带有 package.json 文件的 nodejs 项目(在 ubuntu 上)。 package.json 文件中的一些依赖项指向 git-repositories(带有自签名证书的 gitlab)。

如果我打电话

npm install

npm 应该解析并安装所有依赖项。不幸的是,我收到以下错误消息:

npm ERR! git clone https://git.repository.domain.com/myname/grunt-grunticon-hover.git Cloning into bare repository '/home/dev/.npm/_git-remotes/https-git-repository-domain-com-myname-grunt-grunticon-hover-git-15073ad9'...
npm ERR! git clone https://git.repository.domain.com/myname/grunt-grunticon-hover.git 
npm ERR! git clone https://git.repository.domain.com/myname/grunt-grunticon-hover.git error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://git.repository.domain.com/myname/grunt-grunticon-hover.git/info/refs?service=git-upload-pack
npm ERR! git clone https://git.repository.domain.com/myname/grunt-grunticon-hover.git fatal: HTTP request failed
npm ERR! Error: Command failed: error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://git.repository.domain.com/myname/grunt-grunticon-hover.git/info/refs?service=git-upload-pack

如果我使用“git clone ...”克隆存储库,我没有问题。

我必须安装证书吗?如何安装证书?我在哪里可以找到证书?

我正在使用 ubuntu。

【问题讨论】:

    标签: node.js git ssl certificate npm


    【解决方案1】:

    在你的 package.json 中使用 git+ssh:

    "dependencies": {
      "myname": "git+ssh://git.repository.domain.com/myname/grunt-grunticon-hover.git"
    }
    

    【讨论】:

    • 很遗憾我们的服务器不支持 git+ssh
    • 我没有使用 https 的经验,因此无法说明该方法,但您可能必须支持 ssh 并在要安装模块的机器上拥有证书。
    • 如果我使用“npm install”,"git+https://..." 不起作用。如果我使用“git clone https://...”
    • 您是否已将您的公共 ssh-key 添加到您的 gitlab 个人资料中? (您可以在“我的个人资料”下找到它
    猜你喜欢
    • 2016-01-06
    • 1970-01-01
    • 2017-07-23
    • 1970-01-01
    • 2017-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-29
    相关资源
    最近更新 更多