14

I'm trying to use a private GitLab repo as npm dependency in my node js app, with a private token key, something like this:

"dependencies": {
     "my-module": "git+https://<privateToken>:x-oauth-basic@<myGitLabURL>/<MyUser>/my-module.git"
}

when I run npm install I get errors about the git clone with fatal: unable to access <git repo path> with 443 Connection refused replies.

I couldn't find a lot of documentation of how to do this through https and not through ssh. It seems like it does work on GitHub

Anybody have experience with this on GitLab with Https?

Community
  • 1
  • 1
Zohar Levin
  • 2,364
  • 3
  • 19
  • 24
  • 2
    I used this article and it worked for me. http://stackoverflow.com/questions/28728665/how-to-use-private-github-repo-as-npm-dependency – Stéphane Trottier Jun 24 '16 at 17:56
  • 1
    You need to register your public key in the "Deploy keys" of your project. Long time ago there where an url with a token that let you readonly https access (so npm install too) but it no longer works. It were something like "git+https://gitlab-ci-token:55c302991447875db1242a9e8bcd59@gitlab.com/user/project.git --branch 2.0.0". As far as I know, the only actual (and secure) way now is the "Deploy keys" way. – Carlos Feb 01 '17 at 18:20
  • Possible duplicate of [How to use private Github repo as npm dependency](https://stackoverflow.com/questions/28728665/how-to-use-private-github-repo-as-npm-dependency) – Tiago Bértolo Jul 01 '17 at 22:56

1 Answers1

12

This answer worked for me.

"my-module": "https://oauth2:<PersonalAccessToken>@gitlab.com/<group>/<repository-name>.git

You can create a Personal Access Token under User Settings->Access Tokens (GitLab.com Link).

Splaktar
  • 5,506
  • 5
  • 43
  • 74