当试图使用NPM和GitLab的“实例级”范围/命名空间配置( 404 Not Found )将包发布到私有/自托管GitLab实例的包存储库时,我遇到了一个GitLab错误。
错误
执行$ TOKEN=<ACCESS_TOKEN> npm publish会导致以下错误:
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://gitlab.example.com/api/v4/packages/npm/@org%2fpackage-1 - 404 Not Found
npm ERR! 404
npm ERR! 404 '@org/package-1@0.1.0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.配置
我对国家预防机制的配置如下:
package.json
{
"name": "@org/package-1",
"version": "0.1.0",
"private": false,
"peerDependencies": {
},
"dependencies": {
}
}~/..npmrc
@org:registry=https://gitlab.example.com/api/v4/packages/npm/
//gitlab.example.com/api/v4/packages/npm/:_authToken=$TOKEN
# @org/package-1
//gitlab.example.com/api/v4/projects/<PROJECT_ID>/packages/npm/:_authToken=$TOKEN
# @org/package-2
//gitlab.example.com/api/v4/projects/<PROJECT_ID>/packages/npm/:_authToken=$TOKEN
# @org/package-3
//gitlab.example.com/api/v4/projects/<PROJECT_ID>/packages/npm/:_authToken=$TOKEN发布于 2021-09-10 19:59:51
解决方案
使用与代码存储库关联的publishConfig包存储库的URL将package.json添加到GitLab。
package.json (部分)
"publishConfig": {
"@org:registry": "https://gitlab.example.com/api/v4/projects/<PROJECT_ID>/packages/npm/"
},https://stackoverflow.com/questions/69137470
复制相似问题