importing scoped NPM packages from other registries

In node, I can create an
.npmrc
that has rules like this:

@custom:registry=https://npm.example.com/
//npm.example.com/:_authToken=DEADBEEF

See: https://docs.npmjs.com/cli/v7/configuring-npm/npmrc#comments

This causes
import { foo } from '@custom/foo'
to be loaded from that specified registry instead of the default NPM registry, using the configured
authToken
. It leaves all other NPM packages to continue being retrieved via the default registry.

I don't yet see a way to accomplish this with Deno. Is there one?

What I've tried:

  1. using
    NPM_CONFIG_REGISTRY


This, however, seems to use that configured registry for ALL NPM packages. However, most packages will NOT be found at this specified registry--only the ones in the
@custom
scope. So when it comes to something like
lodash
, it fails trying to fetch
lodash
from
npm.example.com
.

  1. using import maps and DENO_AUTH_TOKEN


{
  "imports": {
    "@custom/": "https://npm.example.com/"
  }
}


And:
export DENO_AUTH_TOKENS="DEADBEEF@npm.example.com"


The problem with this seems to be that Deno does not treat the response as an NPM package, because the specifier in the import map is
https:
. I suppose it's treating it as if it were retrieving a deno package from the denoland package registry.

Is there a way to specify the private registry URL in the import map and that it should be fetched as an NPM package?
Was this page helpful?