通过 NPM 使用来自私有 GitLab 的依赖项 [英] Use dependencies from a private GitLab with NPM

查看:49
本文介绍了通过 NPM 使用来自私有 GitLab 的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从私有 GitLab 实例安装 NPM 依赖项.

I'm trying to install NPM dependencies from a private GitLab instence.

所以,我有基本文件的仓库

So, I have my repo with basic files

我在我的项目的 package.json 中添加了这个依赖项

And I added this dependencie in the package.json on my project

"node-demo-package": "https://oauth2:<ACCESS TOKEN>@gitlab.fullurl.git"

但是,当我运行 npm install 时,我收到以下错误消息:

But, when I run npm install, I receive this error message:

npm ERR! code ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json: node-demo-package@https://oauth2:<ACCESS TOKEN>@gitlab.fullurl.git.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/arnaud.delante/.npm/_logs/2018-01-24T15_05_49_456Z-debug.log

我不明白,因为屏幕截图中显示了 package.json.

Which I don't understand as there is a package.json as showed in the screenshot.

在这里

{
  "name": "demo-package",
  "version": "1.0.0",
  "description": "Test pasckage",
  "main": "index.js",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git@gitlab.fullurl.git"
  },
  "author": "Arnaud Delante",
  "license": "MIT"
}

我已经尝试通过 git+https 切换 https 但又遇到了一个错误

I already tried switching https by git+https but I get another error

npm ERR! Error while executing:
npm ERR! /usr/local/bin/git ls-remote -h -t https://oauth2:<ACCES TOKEN>@gitlab.fullrul.git
npm ERR!
npm ERR! remote: You are not allowed to download code from this project.
npm ERR! fatal: unable to access 'https://oauth2:<ACCES TOKEN>@gitlab.fullrul.git': The requested URL returned error: 403
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/arnaud.delante/.npm/_logs/2018-01-24T17_19_16_677Z-debug.log

这很奇怪,因为令牌是正确的.

Which is weird because the token is correct.

你有什么想法吗?

推荐答案

在 package.json 中尝试将 https:// 替换为 git+https://

In package.json try to replace https:// by git+https://

文档:https://docs.npmjs.com/文件/package.json#git-urls-as-dependencies

这篇关于通过 NPM 使用来自私有 GitLab 的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆