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-tokenVerified import paths — ran on the pinned version, not inferred.
Fetches auth token for default registry and registry URL for a scope. Uses ESM imports as required since v5.
Change to import { getAuthToken } from 'registry-auth-token'Use import { getRegistryUrl } from 'registry-auth-token/registry-url'Upgrade Node.js to version 14 or later
Check if token is truthy before accessing token.token or token.type
Use dynamic import: const { getAuthToken } = await import('registry-auth-token') or switch to ESMChange import to: import { getAuthToken } from 'registry-auth-token'Import from 'registry-auth-token/registry-url': import { getRegistryUrl } from 'registry-auth-token/registry-url'No dependency data recorded yet.