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

encrypted-env

v0.2.1

Published

Encrypt and decrypt env config files quickly and easily

Readme

encrypted-env

ci npm license

encrypted-env is designed to make encrypting and decrypting sensitive .env files a breeze. It's supports using different configuration files for different environments (e.g. development, staging, and production) with different encryption keys for each, and can detect which to load based on existing environmental variavbles.

Installation

npm install encrypted-env

Encrypting / Decrypting

This package provides two commands, env-encrypt and env-decrypt. To encrypt your .env file, run npx env-encrypt. If encrypting for the first time, the user will be prompted to enter in a 32-character key. The key is then stored for future encryption / decryption.

Multiple Environments

Create a .env-encrypted.config.json configuration file in the root of your project that maps environment names to the filename of the configuration file to use.

{
  "development": ".env.dev",
  "staging": ".env.staging",
  "production": ".env.prod"
}

Once defined, you can encrypt and decrypt configuration files for each environment by appending the environment name to the command:

npx env-encrypt staging

This may also be used in the scripts section of your package.json file:

{
  "name": "project-name",
  "scripts": {
    "encrypt:staging": "env-encrypt staging",
    "decrypt:staging": "env-decrypt staging"
  }
}

CI

To enable dynamic decryption in CI, set a secret in the repository and inject it into the process ENV for decryption.

For example, here's a GitHub Actions job that decrypts the env files for a project prior to running integration tests that require them:

  integration-test:
    runs-on: ubuntu-latest
    timeout-minutes: 5

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: 14.x

      - name: Install dependencies
        run: npm install

      - name: Decrypt env
        run: npx env-decrypt
        env:
          ENV_KEY: ${{ secrets.ENV_KEY }}
          CI: true

      - name: Run integration tests
        run: npm run test:integration

Loading configuration in runtime

To load environmental variables into your project:

import loadENV from 'encrypted-env';

const env = loadENV();

If you have multiple environments defined, it will load the config file that corresponds to the environment set in the NODE_ENV or ENVIRONMENT variable.

For example, if the NODE_ENV process env is set to development and the .env-encrypted.config.json file looks like this:

{
  "development": ".env.dev",
  "staging": ".env.staging",
  "production": ".env.prod"
}

Then it will attempt to parse and load .env.dev. If it cannot find .env.dev, it will fail with an error prompting the user to run npx env-decrypt development- which will attempt to create .env.dev from .env.dev.encrypted.

Version Control

Make sure to add these lines to your .gitignore file:

**/*.env
**/*.key

This way, only the encrypted .env files will be pushed to version control.

License

MIT © Jesse Youngblood