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

@hairy/lnv

v9.0.0

Published

_description_

Readme

@hairy/lnv

npm version npm downloads bundle JSDocs License

Loading environment variables in Next.js and other frameworks can be quite cumbersome, and using dotenv or vault at runtime is also inconvenient. That's why my created this tool

I think it can solve some of the problems you encounter in next.js or dotenv or more. 🛠️

✅ Features

  • 🔄 Multi-mode support, allowing you to load .env|.env.prod|.env.local simultaneously
  • 🔐 Support for vault.dotenv remote environment variable loading and multi-environment switching
  • 🛡️ Direct writing to process.env, no local storage, more secure and reliable
  • 📁 Environment variables lookup, naturally supports monorepo architecture
  • 🏃‍♂️ Run any JS and scripts with environment variables
  • 📜 Define your integration config with lnv.config.ts

📦 Install

npm install @hairy/lnv
# or globally
npm install -g @hairy/lnv

🚀 Usage

Modify the scripts field in your package.json:

{
  "scripts": {
    "dev": "lnv staging -- next dev"
  }
}

This will launch next dev with the .env.staging environment variables. ✨

You can also include any run parameters, for example:

lnv prod -- next dev --turbopack

🌿 Default Environment Variables

You don't need any action, the .env.local and .env environment variables will be automatically loaded by default.

🔒 Vault Environment Variables

npx dotenv-vault@latest new
npx dotenv-vault@latest vlt_...
npx dotenv-vault@latest pull
npx dotenv-vault@latest build
```sh
# Create and connect to vault repository
npx dotenv-vault@latest new
# Connect to an existing vault repository
npx dotenv-vault@latest vlt_...

# And encrypt your environment variables:
npx dotenv-vault@latest pull
# or
npx dotenv-vault@latest build

Next, you need to create a .env.key or .env.keys file in your project root directory and write the DOTENV_KEY:

# .env.key
DOTENV_KEY = dotenv://...?environment=development

# or

# .env.keys
DOTENV_KEY_DEVELOPMENT = dotenv://...?environment=development
DOTENV_KEY_CI = dotenv://:...?environment=ci
DOTENV_KEY_STAGING = dotenv://:...?environment=staging
DOTENV_KEY_PRODUCTION = dotenv://:...?environment=production

Finally, you can use the lnv command to include vault environment variables:

# Load environment variables based on .env.vault and .env.key
lnv vault -- node index.js
# Load ci environment variables based on .env.vault and .env.keys
lnv vault:ci -- node index.js

🚢 Vercel with Vault

If you need to deploy on Vercel, you need to add environment variables in your Vercel project:

npx vercel@latest env add DOTENV_KEY

lnv vault will automatically load environment variables based on .env.vault. 🎉

✍️ Manual with environment variables

You can manual load environment variables with the -v|--value parameter:

lnv -v KEY1=value1 -v KEY2=value2 -- node index.js

By adding the $prefix, you can reference the value of an environment variable in the settings or command line:

lnv -v KEY1=value1 -v KEY2=value1 -v KEY3=$KEY1_$KEY2 -- node index.js
## or
lnv -v KEY1=value1 -- node -e 'console.log($KEY1)'

📝 Define Your integration Config

lnv.config.ts is used to add actionable command-line scripts and default injected environment variables.

import fs from 'node:fs/promises'
import { defineConfig } from '@hairy/lnv'

const config = defineConfig({
  /**
   * Environment variable injection, applied to all LNV scripts
   */
  injects: {
    /**
     * Inject before reading environment variables
     */
    before: {
      DB_TYPE: 'mysql',
      DB_HOST: 'localhost',
      DB_PORT: '3306',
      DB_USER: 'root',
    },

    /**
     * Default loaded environment variable entries
     */
    entries: ['local', 'vault', 'remote'],

    /**
     * Inject after reading environment variables
     */
    after: {
      DATABASE_URL: '$DB_TYPE://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME',
    },
  },
})

export default config

The 'scripts' field is used to define operable command-line scripts, which can be understood as scripts in package.json, but with more powerful capabilities.

const config = defineConfig({
  scripts: {
    // command: npm run lnv deploy
    deploy: {
      message: 'Deploy the application',
      prompts: [
        {
          key: 'network',
          message: 'Select Your Network',
          options: [
            { value: 'moonchain', label: 'Moonchain' },
            { value: 'moonchainGeneva', label: 'Moonchain Geneva' },
          ],
        },
        {
          key: 'modulePath',
          message: 'Select the module you want to deploy',
          options: async () => {
            const files = await fs.readdir('./ignition/modules')
            return files.map(file => ({
              value: `./ignition/modules/${file}`,
              label: file.replace('.ts', ''),
            }))
          },
        },
      ],
      command: 'hardhat --build-profile production ignition deploy $modulePath --network $network',
    },
    // command: npm run lnv dev
    dev: {
      message: 'Run the development server',
      command: {
        message: 'Select the project you want to run',
        options: [
          {
            value: 'cd packages/project-1 && npm run dev',
            label: 'project-1',
          },
          {
            value: 'cd packages/project-2 && npm run dev',
            label: 'project-2',
          },
        ],
      },
    },
  },
})

export default config

🔍️ Options

lnv <entry|script> [args]

args:
      --version       show version                                               [boolean]
  -v, --value         set environment variables                                  [array]
  -e, --entry         Explicit loading of entry, same as lnv <entry>             [string]
  -r, --run           load runtime environment and run any scripts               [string]
      --write         expose and write environment variables                     [boolean]
  -d, --depth         depth find and merge environment variables                 [boolean]
  -h, --help          show help                                                  [boolean]

📄 License

MIT License © Hairyf