Npm publish fail on gitlab registry from gitlab CI

Hi,

Since today, I can’t publish my npm package from Gitlab CI to gitlab npm registry (It worked well few days/weeks ago).

The npm publish command throw the following error :

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in.
npm ERR! need auth You need to authorize this machine using `npm adduser`
  • Account on gitlab.com (I’m maintainer of the repo)

  • Gitlab Version : GitLab Enterprise Edition 13.8.0-pre 413d723b2cc

  • Gitlab runners version : 13.7.0-rc1 (98e2e32d)

  • My .gitlab-ci.yml config :

image: node:latest

stages:
  - deploy

deploy:
  stage: deploy
  script:
    - echo "//gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}">.npmrc
    - npm publish

I already checked the npm registry documentation / tutorials and nothing had change on it since I had written my gitlab ci configuration.
I also try to remove the current version of the package and relaunch the build on a commit which worked in the past, without success.

I would be very grateful if you could help me fix my problem or identify a potential new bug.

The error didn’t came from gitlab but from node docker container version. I force a specific version of node docker image (12) to fix it.

I have the same issue. Any idea what changed in the latest node docker image that this does not work anymore?

1 Like

Same. Downgraded to node:15.4.

Any word on what broke this?

Hello,

We are also facing the same issue (npm ERR! need auth You need to authorize this machine using npm adduser ) that after upgrading npm version from v6 to v7 but there is no change in the gitlab runner. I have tried with all possible suggested options as above and from other blogs, but still no luck for us to resolve the issue. Following options have been tried.

  1. Change of node image from latest to 14-buster
  2. Regenerated and added personal access token.
  3. in CI script for generating the .npmrc file, _auth pointed instead of _authToken
  4. Highest npm version 7.21.0 and nodejs 16.x
  5. Downgrade to older version of nodejes 10.x which doesn’t support by the nodejs.
  6. Tried with .npmrc file and “npm configure set xxx” through ci script.

Thanks for your suggestions in advance and appreciate your support.

Regards,
Bala N.

1 Like

Did you get this working @balanandam ?

Try this instead of npm publish:
yarn publish --non-interactive