Registry / auth-security / registry-auth-token

registry-auth-token

JSON →
library5.1.1jsnpmunverified

Retrieves npm registry authentication tokens from .npmrc or programmatic configuration. Current stable version 5.1.1 (Node >=14). Provides both token and type (Bearer/Basic). Also offers registry URL resolution for scopes. Lightweight, no dependencies, ships TypeScript definitions. Critical for tools that need to authenticate with npm registries programmatically.

npm install registry-auth-token
INSTALL
IMPORT
SIG · REGISTRY-AUTH-TOKE
R
registry-auth-token
auth-securityjavascriptv5.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getAuthToken
import { getAuthToken } from 'registry-auth-token'
import getAuthToken from 'registry-auth-token'
ESM named export since v5. Default export is removed in v5; use named import.
getRegistryUrl
import { getRegistryUrl } from 'registry-auth-token/registry-url'
import { getRegistryUrl } from 'registry-auth-token'
Available as a separate subpath export. Not exported from main entry in ESM.
NpmConfig
import type { NpmConfig } from 'registry-auth-token'
TypeScript users can import the NpmConfig type for the options parameter.

Fetches auth token for default registry and registry URL for a scope. Uses ESM imports as required since v5.

import { getAuthToken, getRegistryUrl } from 'registry-auth-token'; const token = getAuthToken(); if (token) { console.log('Token:', token.token); console.log('Type:', token.type); } else { console.log('No token found'); } const registryUrl = getRegistryUrl('@scope'); console.log('Registry URL:', registryUrl);
Debug
Known issues
breakingDefault export removed in v5 - must use named import { getAuthToken } instead of import getAuthToken from '...'
fix
Change to import { getAuthToken } from 'registry-auth-token'
affects: >=5.0.0
breakingSubpath export getRegistryUrl moved to 'registry-auth-token/registry-url' - no longer exposed from main entry
fix
Use import { getRegistryUrl } from 'registry-auth-token/registry-url'
affects: >=5.0.0
breakingDrop support for Node <14 - may fail on older Node versions
fix
Upgrade Node.js to version 14 or later
affects: >=5.0.0
gotchaToken can be undefined - code must handle missing auth gracefully
fix
Check if token is truthy before accessing token.token or token.type
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using require() to load the ESM-only package v5
fix
Use dynamic import: const { getAuthToken } = await import('registry-auth-token') or switch to ESM
SyntaxError: The requested module 'registry-auth-token' does not provide an export named 'default'
Using default import instead of named import in v5
fix
Change import to: import { getAuthToken } from 'registry-auth-token'
getRegistryUrl is not a function
Importing getRegistryUrl from main entry (not available there in v5)
fix
Import from 'registry-auth-token/registry-url': import { getRegistryUrl } from 'registry-auth-token/registry-url'
Upgrade
Version history
5.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
2
Resources
registry-auth-token — npm install registry-auth-token · libregistry