npmgitlab-cicicdnpm-publishpnpm

Gitlab registry pnpm publish fails with 404


I know this is exactly the same question as this one, but I've tried pretty much everything written there without success.

I'm trying to publish a npm package to our local, self-hosted gitlab instance. For this I'm using pnpm and the CI/CD pipeline if that makes a difference.

The error is as follows:

npm notice Publishing to https://my.org.com/api/v4/projects/218/packages/npm/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://my.org.com/api/v4/projects/218/packages/npm/@test-ci-cd-group%2ftest-package
npm ERR! 404 
npm ERR! 404  '@test-ci-cd-group/test-package@1.0.0' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

The URL of the project I'm using as the registry is https://my.org.com/test-ci-cd-group/npm-package-test, so I assume that the @scope is @test-ci-cd-group.

Here are the relevant files:

package.json

{
  "name": "@test-ci-cd-group/test-package",
  "version": "1.0.0",
  "type": "module",
  "module": "./dist/test-package.js",
  "types": "./dist/index.d.ts",
  "files": [
    "dist"
  ],
  "publishConfig": {
    "@test-ci-cd-group:registry": "https://my.org.com/api/v4/projects/218/packages/npm/"
  }
}

.npmrc

@test-ci-cd-group:registry=https://my.org.com/api/v4/projects/218/packages/npm/
//my.org.com/api/v4/projects/218/packages/npm/:_authToken=[MASKED]

--> The second line is added via the pipeline using the following powershell command

echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" | out-file ".npmrc" -Encoding ASCII -Append

It has to be something minor, but I'm really starting to go crazy trying to figure out what I'm doing wrong here.


Solution

  • The problem wasn't the pipeline itself. Our gitlab server uses apache as reverse proxy for https redirects. This causes the server (by default) to reply with a 404 whenever there is an encoded part in the URL. With this behavior turned off the publish works as expected