英文:
Gitlab registry pnpm publish fails with 404
问题
我知道这个问题与这个问题几乎完全相同,但我已经尝试了那里写的几乎所有方法都没有成功。
我正在尝试将一个npm包发布到我们本地的自托管GitLab实例。为此,我使用了pnpm
和CI/CD管道,如果这有所不同的话。
错误如下:
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.
我用作注册表的项目的URL是https://my.org.com/test-ci-cd-group/npm-package-test
,所以我假设@scope
是@test-ci-cd-group
。
以下是相关文件:
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]
--> 第二行是使用以下PowerShell命令通过管道添加的
echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" | out-file ".npmrc" -Encoding ASCII -Append
肯定是一个细微的问题,但我真的开始为了弄清楚我做错了什么而感到疯狂。
英文:
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.
答案1
得分: 0
问题不在于管道本身。我们的gitlab服务器使用apache作为https重定向的反向代理。这会导致服务器(默认情况下)在URL中有编码部分时回复404。将此行为关闭后,发布将按预期进行。
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论