npmrc-replace-env
A utility for dynamically generating .npmrc files based on configuration and environment variables.
Managing npm registry configurations and authentication tokens across different projects and environments can be cumbersome. This package aims to simplify this process by providing a utility that dynamically generates the .npmrc file based on a configuration file (.npmrc.config) and corresponding environment variables (.env).
This approach prioritizes security, preventing inadvertent exposure of sensitive information, like auth tokens in your .npmrc file, in version control systems.
Check out my article for a quick overview and insights about this utility here!
Table of Contents
- Installation
- Usage
- Configuration
- Define Environment Variables in .env
- Command Line Options
- Contributing
- License
Installation
npm install npmrc-replace-env
yarn add npmrc-replace-env
pnpm add npmrc-replace-envNote: While installing the package is an option, it's important to note that it's not required to use the utility. The utility can be invoked directly with npx without installing the package.
Usage
Run the utility using npx:
npx npmrc-replace-envThis will generate a .npmrc file (or override any existing .npmrc files) based on the configuration provided in a file named .npmrc.config.
Configuration
Create a file named .npmrc.config in the root of your project. This file should contain the configuration for your .npmrc file. The utility will replace placeholders in this configuration with corresponding environment variables.
Example .npmrc.config: