I am trying to publish a private NPM package on a self-hosted GitLab.
To do this, I created a GitLab project having ID = 9
, to host all the NPM packages that I need.
The package.json
of the lib is:
{
"name": "@myscope/api-client",
"version": "1.0.0",
...
...
...
"publishConfig":{
"@myscope:registry": "https://gitlab.mydomain.eu/api/v4/projects/9/packages/npm/"
}
}
and the following is the .npmrc
file:
@myscope:registry=https://gitlab.mydomain.eu/api/v4/packages/npm/
//gitlab.mydomain.eu/api/v4/packages/npm/:_authToken=${GITLAB_AUTH_TOKEN}
//gitlab.mydomain.eu/api/v4/projects/9/packages/npm/:_authToken=${GITLAB_AUTH_TOKEN}
Considering the online documentation I'm not getting what's missing.
However, when running the npm publish
command I get a 404 Not Found - PUT
error.
The provided access token has all permissions just to exclude this possibility.
$ GITLAB_AUTH_TOKEN=MyAccessToken npm publish dist
...
...
...
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://gitlab.mydomain.eu/api/v4/packages/npm/@myscope%2fapi-client
npm ERR! 404
npm ERR! 404 '@myscope/api-client@1.0.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.
UPDATE
I did also try with the following .npmrc
without success, based on the doc at https://docs.gitlab.com/ee/user/packages/npm_registry/index.html#authenticate-with-a-ci-job-token.
@myscope:registry=https://gitlab.mydomain.eu/api/v4/projects/9/packages/npm/
//gitlab.mydomain.eu/api/v4/projects/9/packages/npm/:_authToken=${GITLAB_AUTH_TOKEN}