Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use dependencies from a private GitLab with NPM

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

So, I have my repo with basic files

enter image description here

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

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

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

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

Here it is

{
  "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": "[email protected]"
  },
  "author": "Arnaud Delante",
  "license": "MIT"
}

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.

Would you have any idea?

like image 802
Axiol Avatar asked Jan 24 '18 16:01

Axiol


1 Answers

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

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

like image 97
Gabriel Bleu Avatar answered Nov 17 '22 23:11

Gabriel Bleu