Reputation: 91
I encounter a 404 Not Found
error when attempting to publish a package to a package repository of a private/self-hosted instance of GitLab using NPM and GitLab's 'instance-level' scope/namespace configuration (reference).
Executing $ TOKEN=<ACCESS_TOKEN> npm publish
results in the following error:
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/[email protected]' 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.
My configuration of NPM is as follows:
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
Upvotes: 2
Views: 5635
Reputation: 91
Add publishConfig
to package.json
with the URL of the GitLab package repository associated with the code repository.
package.json (partial)
"publishConfig": {
"@org:registry": "https://gitlab.example.com/api/v4/projects/<PROJECT_ID>/packages/npm/"
},
Upvotes: 3