Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

387
Views
In a Github Action how to reference a private package for a test?

I have written a test file for a Github Action:

test.yml

name: Test
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x, 16.x]
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm ci
      - run: npm run build --if-present
      - run: npm test

but my package.json uses an organization private repo. When the Github Action runs it fails and I get the error:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@org/repo/
npm ERR! 404 
npm ERR! 404  '@org/repo@1.2.3' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-02-10T17_17_46_961Z-debug.log
Error: Process completed with exit code 1.

My research trying to solve the issue:

  • Package is not publishing to npm (not in the npm registry)
  • Getting 404 when attempting to publish new package to NPM
  • Installing npm package fails with 404
  • 404 error while publishing npm package - npm ERR! 404 Not Found - PUT https://registry.npmjs.org/

In my Github Action how can I properly reference the private org repo so that my test will work correctly or is there a step I'm missing?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You have to add authorization to on CI with URL + token - it's done through .npmrc file.

  1. Create a token: npm token create --read-only

  2. Add it to your secrets on GitHub named NPM_TOKEN

  3. Before running npm ci create a local file with your token:

    Add a step: - run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc

Everything else stays as it is.

over 4 years ago · Santiago Trujillo Report

0

This answer was correct and here is the sample test.yml file now:

name: Test
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x, 16.x]
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node-version }}
      - run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
      - run: npm ci
      - run: npm run build --if-present
      - run: npm test

Github Action shows as passed:

jobs

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!