Unable to install published package

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
2 Likes

Hello, I am having the very same issue on one particular package. Is there any info how to get over the problem?

Here is the built package: Package Registry · Virtual Dimensions · GitLab
And here is the .gitlab-ci.yml that triggered the build: https://gitlab.com/vdimensions/infra/rollup-js-helpers/-/blob/master/.gitlab-ci.yml

Just as the OP I am getting 404 error when doing npm install

I’ve found the problem. The 404 status code is misleading though. The real reason was that I have published the package as part of a CI job, while the project access was set to Private. I overlooked this setting when I created the gitlab project initially as I intended it to be publuc. However, when the project is private, any npm pckages that are stored in gitlab’s npm registry cannot be used (unless special auhentication is performed).

Here are the steps to fix:

  1. Update your project to be Public
  2. Make sure that the project has package registry setting enabled
  3. Delete any previously created packages and re-created them by re-running the CI. This is because the old package is still inacessible as it was created while the project was private
  4. Run npm install again, the package should now resolve with no issues

Here is additional info that helped me: npm packages in the Package Registry | GitLab

1 Like