FabianoLothor
FabianoLothor

Reputation: 2967

Import a private repository from linux

The code below works fine with Windows with the command mpm i.

  "dependencies": {
    "my-pack": "git+https://myprivategit.com/my/repo#v0.1.0"
  },

A credential form standard of windows is open, and the login and password is passed.

But on Linux an authetication error is returned.

npm install
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://myprivategit.com/my/repo
npm ERR!
npm ERR! remote: HTTP Basic: Access denied
npm ERR! fatal: Authentication failed for 'https://myprivategit.com/my/repo.git/'
npm ERR!
npm ERR! exited with error code: 128

Upvotes: 1

Views: 697

Answers (2)

jschaefer
jschaefer

Reputation: 81

What worked for me was to do the npm install together with my ssh key stored in .ssh.

npm install git+ssh://git@your_git_server.com:your_username/your_private_repo_name.git

I followed this tutorial.

Upvotes: 0

Nathan
Nathan

Reputation: 8141

Looks like you need to add your credentials, can you try the following:

  1. Generate an access token for the repository you wish to npm install from. For example, go here to create an access token.
  2. Prefix your GIT Repo within your package.json to use the access token generated from step 1:

    "dependencies": { "my-pack": "git+https://<token>:[email protected]/<user>/myprivategit.com/my/repo#v0.1.0" },

or:

Create a .netrc within your home directory and give it the necessary credentials to login:

touch ~/.netrc

.netrc:

machine github.com login <token>

then just leave the url to your private repo as is within your .package.json

Upvotes: 1

Related Questions