Node.js – how to use private GitLab repository as npm dependency with private token through https

gitlabhttpsnode.jsnpm

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?

Best Answer

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).

Related Topic