{"id":18740,"library":"registry-auth-token","title":"registry-auth-token","description":"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.","status":"active","version":"5.1.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/rexxars/registry-auth-token","tags":["javascript","npm","conf","config","npmconf","registry","auth","token","authtoken","typescript"],"install":[{"cmd":"npm install registry-auth-token","lang":"bash","label":"npm"},{"cmd":"yarn add registry-auth-token","lang":"bash","label":"yarn"},{"cmd":"pnpm add registry-auth-token","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM named export since v5. Default export is removed in v5; use named import.","wrong":"import getAuthToken from 'registry-auth-token'","symbol":"getAuthToken","correct":"import { getAuthToken } from 'registry-auth-token'"},{"note":"Available as a separate subpath export. Not exported from main entry in ESM.","wrong":"import { getRegistryUrl } from 'registry-auth-token'","symbol":"getRegistryUrl","correct":"import { getRegistryUrl } from 'registry-auth-token/registry-url'"},{"note":"TypeScript users can import the NpmConfig type for the options parameter.","wrong":"","symbol":"NpmConfig","correct":"import type { NpmConfig } from 'registry-auth-token'"}],"quickstart":{"code":"import { getAuthToken, getRegistryUrl } from 'registry-auth-token';\n\nconst token = getAuthToken();\nif (token) {\n  console.log('Token:', token.token);\n  console.log('Type:', token.type);\n} else {\n  console.log('No token found');\n}\n\nconst registryUrl = getRegistryUrl('@scope');\nconsole.log('Registry URL:', registryUrl);","lang":"typescript","description":"Fetches auth token for default registry and registry URL for a scope. Uses ESM imports as required since v5."},"warnings":[{"fix":"Change to import { getAuthToken } from 'registry-auth-token'","message":"Default export removed in v5 - must use named import { getAuthToken } instead of import getAuthToken from '...'","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Use import { getRegistryUrl } from 'registry-auth-token/registry-url'","message":"Subpath export getRegistryUrl moved to 'registry-auth-token/registry-url' - no longer exposed from main entry","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Upgrade Node.js to version 14 or later","message":"Drop support for Node <14 - may fail on older Node versions","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Check if token is truthy before accessing token.token or token.type","message":"Token can be undefined - code must handle missing auth gracefully","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'14':20 '5.1.1':18 'also':27 'auth':3,57 'authent':8,46 'authtoken':59 'bearer/basic':26 'conf':53 'config':54 'configur':14 'critic':40 'current':15 'definit':39 'depend':36 'javascript':51 'lightweight':34 'need':44 'node':19 'npm':6,48,52 'npmconf':55 'npmrc':11 'offer':28 'programmat':13,50 'provid':21 'registri':2,7,29,49,56 'registry-auth-token':1 'resolut':31 'retriev':5 'scope':33 'ship':37 'stabl':16 'token':4,9,23,58 'tool':42 'type':25 'typescript':38,60 'url':30 'version':17","created_at":"2026-04-25T07:39:52.642659+00:00","updated_at":"2026-04-25T07:39:52.642659+00:00","problems":[{"fix":"Use dynamic import: const { getAuthToken } = await import('registry-auth-token') or switch to ESM","cause":"Using require() to load the ESM-only package v5","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Change import to: import { getAuthToken } from 'registry-auth-token'","cause":"Using default import instead of named import in v5","error":"SyntaxError: The requested module 'registry-auth-token' does not provide an export named 'default'"},{"fix":"Import from 'registry-auth-token/registry-url': import { getRegistryUrl } from 'registry-auth-token/registry-url'","cause":"Importing getRegistryUrl from main entry (not available there in v5)","error":"getRegistryUrl is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/rexxars/registry-auth-token","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/registry-auth-token","openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}