node.js - 从 Gitlab 私有存储库导入节点模块时出错
问题描述
设想:
- 我开发了某种节点模块。
- 后来我才知道,与其将我的节点模块发布到 npm 存储库,我可以使用我自己的 Gitlab 存储库将其用作节点模块。
约束是:
- 我必须为此活动使用私人仓库
- 我必须使用 https url 来获取 repo
因此,在谷歌搜索了几个小时后,我找到了一个解决方案,其中包括直接来自 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
解决方案
假设您按照此SO 答案中提到的步骤设置访问令牌
您可以尝试删除项目 url 末尾的 .git 扩展名,所以它应该看起来像
"my-module": "git+https://myusername:myaccesstoken@gitlab.com:organization/project#develop"
所以后面的一切都@
应该是你在地址栏中看到的 gitlab 上项目的确切 URL
推荐阅读
- javascript - Javascript mic-recorder-to-mp3 仅适用于重新编译
- java - 如何混合多个 PCM 音频包(语音流)
- jquery - 如何将点击处理程序添加到自定义 jQuery UI 小部件并在处理程序中使用小部件的属性?
- python - 在 python 程序上执行多线程
- string - Grep 一个完全匹配的 IP 和随机字符串之间的匹配
- java - Jackson Databind Objectmapper 2.10 - 不工作
- java - JavaFX 默认 onAction 效果
- sql - 带有内部选择子句的sql order by和group by rollup
- javascript - AsyncStorage 不存储数据
- php - 路由laravel中的正则表达式?