npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

update-env

v1.0.0

Published

A utility package for environment variable management

Readme

Update Env Utils

A TypeScript utility package for managing environment variables with both programmatic API and CLI interface.

Installation

Global Installation (for CLI usage)

npm install -g update-env-utils

Local Installation (for programmatic usage)

npm install update-env-utils

CLI Usage

After global installation, you can use the update-env command:

Set an environment variable

update-env set API_KEY "your-api-key-here"
update-env set DATABASE_URL "postgresql://localhost:5432/mydb"

Get an environment variable

update-env get API_KEY

List all environment variables

update-env list

Delete an environment variable

update-env delete API_KEY

Use a custom .env file

update-env set API_KEY "value" --file .env.production
update-env list --file .env.development

Programmatic Usage

Basic Usage

import EnvUpdater from 'update-env-utils';

const envUpdater = new EnvUpdater('.env');

// Set a variable
envUpdater.updateVar('API_KEY', 'your-api-key');

// Get a variable
const apiKey = envUpdater.getVar('API_KEY');

// List all variables
envUpdater.listVars();

// Delete a variable
envUpdater.deleteVar('API_KEY');

Using with Custom File Path

import EnvUpdater from 'update-env-utils';

const prodEnv = new EnvUpdater('.env.production');
prodEnv.updateVar('NODE_ENV', 'production');

const devEnv = new EnvUpdater('.env.development');
devEnv.updateVar('NODE_ENV', 'development');

API Reference

EnvUpdater Class

Constructor

  • new EnvUpdater(envFilePath?: string) - Creates a new instance with optional custom .env file path (defaults to '.env')

Methods

  • readEnvFile(): Record<string, string> - Reads and parses the environment file
  • writeEnvFile(envVars: Record<string, string>): void - Writes environment variables to file
  • updateVar(key: string, value: string): void - Updates or creates an environment variable
  • getVar(key: string): string | undefined - Gets the value of an environment variable
  • listVars(): void - Lists all environment variables to console
  • deleteVar(key: string): void - Deletes an environment variable

Development

Setup

# Clone the repository
git clone <repository-url>
cd update-env

# Install dependencies
npm install

# Build the project
npm run build

# Watch for changes during development
npm run dev

Scripts

  • npm run build - Compile TypeScript to JavaScript
  • npm run dev - Watch mode for development
  • npm run clean - Remove dist directory
  • npm run start - Run the compiled main file
  • npm test - Run tests (placeholder)

Publishing to npm

First-time setup

  1. Create an npm account at https://www.npmjs.com/
  2. Login to npm:
    npm login

Publishing process

# Build the project
npm run build

# Publish (this will automatically run prepublishOnly script)
npm publish

# Or use the version bump scripts:
npm run publish:patch  # 1.0.0 -> 1.0.1
npm run publish:minor  # 1.0.0 -> 1.1.0
npm run publish:major  # 1.0.0 -> 2.0.0

Before publishing checklist

  • [ ] Update version in package.json
  • [ ] Update changelog/release notes
  • [ ] Test the CLI commands locally
  • [ ] Run npm run build successfully
  • [ ] Verify the dist/ directory contains compiled files
  • [ ] Test installation locally: npm pack and npm install -g ./update-env-utils-1.0.0.tgz

Project Structure

update-env/
├── src/
│   └── main.ts          # Main TypeScript source file
├── bin/
│   └── cli.js           # CLI executable
├── dist/                # Compiled JavaScript (generated)
├── package.json         # Package configuration
├── tsconfig.json        # TypeScript configuration
└── README.md           # This file

License

MIT

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request