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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ask-env

v0.0.2

Published

CLI to interactively setup and manage .env files. Prompt users for environment variable values and automatically update configuration files.

Readme

ask-env

A CLI tool to interactively setup and manage .env files. Prompt users for environment variable values and automatically update your configuration files.

Features

  • 🎯 Interactive prompts for environment variables
  • ✨ Support for required and optional variables
  • 📝 Automatic .env file creation and updates
  • 🔄 Preserve existing values when prompting
  • 📁 Customizable file path support
  • 🚀 Simple and intuitive CLI interface

Installation

npm install -g ask-env
# or
pnpm add -g ask-env
# or
yarn global add ask-env

Usage

Basic Usage

Prompt for a single environment variable:

ask-env API_KEY

Prompt for multiple environment variables:

ask-env API_KEY DATABASE_URL PORT

Specify Custom File

By default, ask-env edits the .env file in the current directory. You can specify a different file using the -f or --file option:

ask-env API_KEY -f .env.local
ask-env API_KEY DATABASE_URL --file .env.production

Variable Types

Required Variables

Variables are required by default. Users must provide a value:

ask-env API_KEY

Optional Variables

Prefix the variable name with ?: to make it optional:

ask-env '?:DEBUG_MODE' '?:LOG_LEVEL'

Custom Prompts

You can customize the prompt message by using the format message:param:name:

ask-env 'url for:!:API_URL' 'optional email for:?:ADMIN_EMAIL'
  • The first part is the message displayed to the user
  • The second part is the parameter type: ! for required, ? for optional
  • The third part is the actual environment variable name

Examples:

# Custom message with required variable
ask-env 'Please enter your API key:!:API_KEY'

# Custom message with optional variable
ask-env 'Enter your email (optional):?:ADMIN_EMAIL'

How It Works

  1. ask-env reads the existing .env file (if it exists)
  2. For each variable specified, it prompts the user for a value
  3. If a value already exists in the .env file, it's shown as the default
  4. New or changed values are written back to the file
  5. Values that remain unchanged are not modified

Examples

Example 1: Setup Development Environment

ask-env 'Database URL:!:DATABASE_URL' 'Redis URL:!:REDIS_URL' 'Debug mode:?:DEBUG'

This will prompt for DATABASE_URL and REDIS_URL (required), and DEBUG (optional).

Example 2: Update Production Config

ask-env API_KEY PRODUCTION_URL --file .env.production

Example 3: Initialize New Project

ask-env \
  'Application name:!:APP_NAME' \
  'Port:!:PORT' \
  'Database URL:!:DATABASE_URL' \
  'Secret key:!:SECRET_KEY' \
  'Debug mode:?:DEBUG'

Development

Install Dependencies

npm install

Run Tests

npm test

Manual Testing

# Test with required variables
node index.js TEST TEST2 -f .env.local

# Test with mixed required/optional variables
node index.js 'url for:TEST' 'optionalurl for:?:TEST3' TEST2 -f .env.local

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.