繁体   English   中英

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

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

场景:

  • 我已经开发了某种节点模块。
  • 后来我才知道,不是将节点模块发布到npm存储库,而是可以使用自己的Gitlab存储库将其用作节点模块。

约束是:

  • 我必须为此活动使用私人仓库
  • 我必须使用https网址来获取存储库

因此,在搜寻了几个小时之后,我找到了一个解决方案,该解决方案包括直接从git存储库中包含dependecy。

因此,我的依赖看起来像:

    "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

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

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

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

因此@之后的所有内容都应该是gitlab上项目的确切URL,如您在地址栏中看到的那样

暂无
暂无

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

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