Npm login error in Gilab CI

Hi there

I’m having trouble running the Gitlab CI to run node. Facing npm login error. How can we avoid this issue?

Thanks.

Problem to solve

npm login fails in Gitlab CI

$ npm ci
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: /root/.npm/_logs/2024-04-25T13_17_02_007Z-debug-0.log
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 1

Configuration

image: node:latest

pages:
  stage: deploy
  before_script:
    - npm ci
  script:
    - apt update && apt install -y libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev libasound2
    - npm install
    - npm run build
  artifacts:
    paths:
      - build
  only:
    - rsrividhya-com

Versions

Please select whether options apply, and add the version information.

  • Self-managed
  • GitLab.com SaaS
  • Self-hosted Runners