Skip to content

npm scoped packages and lockfile installs ​

In Repositories, create the npm Hosted repository npm-hosted and the Proxy npm-upstream pointing to https://registry.npmjs.org/. Create npm-public as a Group with npm-hosted first and npm-upstream second. Publish to Hosted and install from Group, which serves merged metadata and tarballs.

Replace the example domain with your instance’s public address. Inject ARKA_TOKEN from the CI secret store. A token inherits the permissions of the account that created it. Grant the publisher write on Hosted and private consumers read on Group and its relevant members. Keep the environment variable references in the project’s .npmrc.

ini
registry=https://packages.example.org/repository/npm-public/
@acme:registry=https://packages.example.org/repository/npm-public/
//packages.example.org/repository/npm-public/:_authToken=${ARKA_TOKEN}
//packages.example.org/repository/npm-hosted/:_authToken=${ARKA_TOKEN}

Pin the publish destination in package.json so scoped routing still publishes to Hosted.

json
{
  "name": "@acme/example",
  "version": "1.0.0",
  "main": "index.js",
  "publishConfig": { "@acme:registry": "https://packages.example.org/repository/npm-hosted/", "registry": "https://packages.example.org/repository/npm-hosted/" }
}

Create index.js in the publishing project and run npm publish. Then run these commands in a consuming project that uses the .npmrc above.

bash
npm install --save-exact @acme/example@1.0.0
npm ci --cache "$(mktemp -d)"
npm ls @acme/example

The first command generates or updates package-lock.json. Commit the lockfile and use npm ci in CI. Inspect resolved and integrity when debugging installs. Older lockfiles may retain the previous hostname. For 401s, check the token path and that the environment variable was injected. If metadata loads but tarball downloads fail, check the public base URL, Group member access, and how the reverse proxy forwards encoded scoped-package paths.

Released under the Apache 2.0 License.