Hi there,
I’m trying to publish a test for a npm package but it constantly fails.
In my package.json I have named the package after “@username/package_name” and also configured the publishConfig object:
"publishConfig": {
"@username:registry": "https://gitlab.com/api/v4/projects/<projectID>/packages/npm"
},
My CICD YAML file is configured this way:
image: node:latest
stages:
- publish
publish:
stage: publish
script:
- echo "@username:registry=https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc
- echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
- npm publish
and it fails with
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://gitlab.com/api/v4/projects/<projectID>/packages/npm
I’ve read a lot, tried to downgrade node version to 20, 18 and even 16. I followed tutorials and Gitlab documentation. Nothing seems to work.
Any thoughts on what’s wrong?