简体   繁体   English

从Gitlab私有存储库导入节点模块时出错

[英]Error while importing a node module from Gitlab private repository

Scenario: 场景:

  • I have developed a node module of some sort. 我已经开发了某种节点模块。
  • Later on I came to know, instead of publishing my node module to the npm repository, I could use my own Gitlab repo to serve it as a node module. 后来我才知道,不是将节点模块发布到npm存储库,而是可以使用自己的Gitlab存储库将其用作节点模块。

Constraints are: 约束是:

  • I have to use the private repo for this activity 我必须为此活动使用私人仓库
  • I have to use the https url for fetching the repo 我必须使用https网址来获取存储库

So after googling for a couple of hours, I landed upon a solution, which involved including the dependecy directly from the git repository. 因此,在搜寻了几个小时之后,我找到了一个解决方案,该解决方案包括直接从git存储库中包含dependecy。

Thus my dependency looks like: 因此,我的依赖看起来像:

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

If I execute npm install it would result in: 如果我执行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

Assuming you followed the steps to setup an access token as mentioned in this SO answer 假设您按照此SO答案中所述的步骤设置访问令牌

can you try removing the .git extension at the end of the project url, so it should look like 您可以尝试删除项目网址末尾的.git扩展名吗,所以它看起来应该像

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

so everything after @ should be the exact URL of the project on gitlab as you see in the address bar 因此@之后的所有内容都应该是gitlab上项目的确切URL,如您在地址栏中看到的那样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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