{"library":"npmrc-replace-env","title":"npmrc-replace-env","description":"npmrc-replace-env is a Node.js utility designed to simplify the management of npm registry configurations and authentication tokens across various projects and environments. It dynamically generates or updates a `.npmrc` file based on a user-defined `.npmrc.config` template and corresponding environment variables, which can be loaded from `.env` files. The current stable version is 1.2.1. The project follows a regular release cadence with frequent patch releases addressing bug fixes and dependency updates, alongside minor releases introducing new features like shell-style variable syntax support. Its primary differentiator is its focus on securely managing sensitive npm configuration details by preventing their exposure in version control, leveraging environment variables for token replacement. It supports both prefix-based (`NPMRC_TOKEN`) and shell-style (`$TOKEN`, `${TOKEN}`) placeholder syntax, offering flexibility for different CI/CD environments, including GitHub Actions. The tool is primarily used via its command-line interface with `npx` and requires Node.js version 24.0.0 or higher for current versions.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install npmrc-replace-env"],"cli":{"name":"npx","version":null}},"imports":["npx npmrc-replace-env","import type { NpmrcReplaceEnvOptions } from 'npmrc-replace-env';","import type { NpmrcReplaceEnvError } from 'npmrc-replace-env';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"mkdir my-project\ncd my-project\n\n# Create a configuration template\ncat <<EOF > .npmrc.config\n# .npmrc.config for my-project\n@myorg:registry=https://private.registry.com/myorg\n//private.registry.com/myorg/:_authToken=NPMRC_MY_ORG_TOKEN\n\n@otherorg:registry=https://another.registry.com/\n//another.registry.com/:_authToken=\\${OTHER_ORG_TOKEN}\nEOF\n\n# Create an .env file with your tokens (add .npmrc to .gitignore immediately!)\ncat <<EOF > .env\nNPMRC_MY_ORG_TOKEN=your_private_token_12345\nOTHER_ORG_TOKEN=your_other_token_67890\nEOF\n\n# Generate the .npmrc file\nnpx npmrc-replace-env\n\n# Verify the generated .npmrc\ncat .npmrc\n\n# Expected output in .npmrc:\n# @myorg:registry=https://private.registry.com/myorg\n# //private.registry.com/myorg/:_authToken=your_private_token_12345\n#\n# @otherorg:registry=https://another.registry.com/\n# //another.registry.com/:_authToken=your_other_token_67890\n","lang":"bash","description":"Demonstrates how to set up a `.npmrc.config` and `.env` file, then use `npx npmrc-replace-env` to generate a `.npmrc` with environment variables replaced.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}