skip to Main Content

There is a public NPM package in the Github Package Registry im trying to install using Github Actions.

I have added a .npmrc file next to my package.json with the line @instacart:registry=https://npm.pkg.github.com.

I have added the package to dependencies in my package.json;

  "dependencies": {
    "@instacart/radium": "^0.26.6"
  }

My Github Actions workflow is as follows;

name: Install

on: push

jobs:
  install:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - run: npm install

I am able to run npm install locally without any problem, but the Github Actions workflow fails;

> Run npm install
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR!     https://www.npmjs.com/forgot
npm ERR! 
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR!     npm login

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

Why is this error appearing? Why is it working fine locally, but not in the Github Actions workflow? Why is it asking for login credentials when the package is public?

Any help is much appreciated:)

2

Answers


  1. A personal access token with the read:packages scope is required to download and install public packages from the GitHub npm registry. See docs for details.

    Login or Signup to reply.
  2. You need to set GITHUB_ENV in your step env (the GITHUB_TOKEN secret is automatically filled by GitHub):

    jobs:
      install:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v3
          - uses: actions/setup-node@v3
            with:
              node-version: 16
          - name: Install dependencies
            env:
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
            run: npm install
    

    and you also need to give read permission to your repository in package settings:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search