I'm encountering an issue during my GitHub Actions workflow where the npm install step fails with the following error:
npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
I have a release.yml file for my workflow, and I'm setting up my .npmrc file with the necessary registry information and authentication token using GitHub secrets. However, I'm still facing this authentication error.
Here's a snippet from my release.yml file:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: latest
- name: Create .npmrc
run: |
echo "@***:registry=https://***" > .npmrc
echo "@***:registry=https://***" >> .npmrc
echo "@***:registry=https://***" >> .npmrc
echo "registry=https://registry.npmjs.org" >> .npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_ACCESS_KEY }}" >> .npmrc
echo "always-auth = true" >> .npmrc
- run: ls -ail
- run: npm version
- run: npm install --legacy-peer-deps
- run: npm run build-web:prod release
I've double-checked my registry information and authentication token, but the issue persists. What could be causing this authentication error, and how can I resolve it?