I successfully published a package in a private repository of my organisation. In my global .npmrc I have the following:
# Set URL for your scoped packages.
@<main-package-name>:registry=https://gitlab.<my-organisation-domain>/api/v4/packages/npm/
'//gitlab.<my-organisation-domain>/api/v4/packages/npm/:_authToken'="<my-token>"
'//gitlab.<my-organisation-domain>/api/v4/projects/<my-project-id>/packages/npm/:_authToken'="<my-token>"
In the package.json file I have the following properties:
"publishConfig": {
"@<main-package-name>:registry": "https://gitlab.<my-organisation-domain>/api/v4/projects/<my-package-id>/packages/npm/"
},
"name": "@<main-package-name>/<library-name>",
...
On GitLab, it says the following:
Installation
npm i @<main-package-name>/<library-name>
Registry setup
echo @<main-package-name>:registry=https://gitlab.<my-organisation-domain>/api/v4/packages/npm/ >> .npmrc
I added "@<main-package-name>/<library-name>": "~0.0.11"
to the project’s package.json, but when I try and run npm install I get:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@<main-package-name>/<library-name> - Not found
npm ERR! 404
npm ERR! 404 '@<main-package-name>/<library-name>@~0.0.11' 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.
npm ERR! A complete log of this run can be found in:
npm ERR! /path/to/log