How to install private git repository as a dependency in the package.json

Hi,

I’m trying to install npm (running npm ci) using a private dependency in my package.json but I got this error:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/organization/test-services.git
npm ERR! 
npm ERR! ERROR: Repository not found.
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR! 
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/circleci/project/node_modules/_logs/2022-10-27T06_09_29_047Z-debug.log


Exited with code exit status 1
CircleCI received exit code 1

I already have done the machine user configuration and this user has access to all my private repositories that I need to use

This is my config.yml:

version: 2.1

orbs:
  node: circleci/node@5.0.2

executors:
  node14:
    docker:
      - image: 'cimg/node:14.18.2'
    resource_class: medium

commands:
  nodesetup:
    description: checkout code, restore cache, install dependencies, save cache
    steps:
      - checkout
      - node/install-packages:
         cache-path: ~/project/node_modules
         app-dir: ~/project/

jobs:
  build_and_test:
    executor: 'node14'
    steps:
      - add_ssh_keys:
          fingerprints:
            - "zz:zz:zz:zz:zz:zz:zz:zz:zz:zz:zz:zz:zz:zz:zz:ba"
      - nodesetup
  
workflows:
  pipeline:
    jobs:
      - build_and_test

My package.json:

"author": "",
  "license": "ISC",
  "dependencies": {
    "private-repo": "github:organization/private-repo"
  },
  "devDependencies": {
    "@organization/test-services": "github:organization/test-services",
    "aws-sdk-mock": "^5.5.1",
    "chai": "^4.3.6",
    "nyc": "^15.1.0",
    "redis-mock": "^0.56.3",
    "sinon": "^9.2.3",
    "sinon-chai": "^3.5.0"
  },

The public key is already stored in github, the private in circleci and I reference it using the fingerprint. Please help, thanks in advance.

I solved the problem including - run: git config --global url."git@github.com:".insteadOf "git://github.com/"before de nodesetup step and just clicking in the user key button (in the project configuration/ssh keys) for the integration with github without any private key.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.