如何使用私有GitLab存储库作为npm依赖与私有令牌通过https

Zoh*_*vin 12 https node.js npm gitlab

我试图在我的节点js应用程序中使用私有GitLab repo作为npm依赖项,使用私有令牌密钥,如下所示:

"dependencies": {
     "my-module": "git+https://<privateToken>:x-oauth-basic@<myGitLabURL>/<MyUser>/my-module.git"
}
Run Code Online (Sandbox Code Playgroud)

当我运行时,npm install我得到关于git克隆的错误fatal: unable to access <git repo path>与443 Connection拒绝回复.

我找不到很多关于如何通过https而不是通过ssh执行此操作的文档.它似乎适用于GitHub

有没有人在使用Https的GitLab上有这方面的经验?

Spl*_*tar 9

这个答案对我有用.

"my-module": "https://oauth2:<PersonalAccessToken>@gitlab.com/<group>/<repository-name>.git
Run Code Online (Sandbox Code Playgroud)

您可以在用户设置 - >访问令牌(GitLab.com链接)下创建个人访问令牌.