[FIXED] Unable to install public NPM-package from Github Package Registry using Github Actions

Issue

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:)

Solution

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.

Answered By – tinaheidinger

Answer Checked By – Laura B. (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published