首页 > 解决方案 > 从 Gitlab 私有存储库导入节点模块时出错

问题描述

设想:

约束是:

因此,在谷歌搜索了几个小时后,我找到了一个解决方案,其中包括直接来自 git 存储库的依赖项。

因此我的依赖看起来像:

    "my-module": "git+https://myusername:myaccesstoken@gitlab.com:Organization/Project.git#develop"

如果我执行npm install它将导致:

npm ERR! Error while executing: npm ERR! /usr/bin/git ls-remote -h -t ssh://git@gitlab.com/organization/project.git npm ERR! npm ERR! Permission denied (publickey). npm ERR! fatal: Could not read from remote repository. npm ERR! npm ERR! Please make sure you have the correct access rights npm ERR! and the repository exists. npm ERR! npm ERR! exited with error code: 128 npm ERR! A complete log of this run can be found in: npm ERR! /home/username/.npm/_logs/2018-05-16T13_25_37_053Z-debug.log

标签: node.jsgitnpmgitlabnode-modules

解决方案


假设您按照此SO 答案中提到的步骤设置访问令牌

您可以尝试删除项目 url 末尾的 .git 扩展名,所以它应该看起来像

"my-module": "git+https://myusername:myaccesstoken@gitlab.com:organization/project#develop"

所以后面的一切都@应该是你在地址栏中看到的 gitlab 上项目的确切 URL


推荐阅读