将私有GitLab中的依赖项与NPM结合使用 [英] Use dependencies from a private GitLab with NPM

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

问题描述

我正在尝试从私有的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://

doc: https://docs.npmjs.com /files/package.json#git-urls-as-dependencies

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

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