next-env-cmd

Load .env files using @next/env module


Keywords
env, next, cmd, cli, file
License
MIT
Install
npm install next-env-cmd@0.1.0

Documentation

next-env-cmd

CLI command for loading .env files using @next/env and spawn process using cross-spawn modules.

Note: This is a standalone command and can be used without installing Next.js framework.

Install

$ npm install next-env-cmd

Usage

Use Next.js Environment Variables filename format.

/.env
/.env.development
/.env.development.local
/.env.test
/.env.test.local

And then in package.json.

{
  "script": {
    // defaults to load development env vars
    "dev": "next-env-cmd node start.js",
    // load production env vars in home directory
    "start": "NODE_ENV=production next-env-cmd -d ~/ node start.js",
    // load test env vars for testing (using alias "nexenv")
    "test": "NODE_ENV=test nexenv jest"
  }
}

Additional command options.

Usage: next-env-cmd [options] <command> [...args]

Examples:
  $ next-env-cmd node start.js          # load .env files in CWD
  $ next-env-cmd -d ~/ node start.js    # load .env files in ~/
  $ nexenv -p ../ node start.js         # alias shorthand command

Options:
  -v, --version        output the version number
  -d, --dir [path]     Custom env directory path (default: "./")
  -p, --parent [path]  Parent env directory path to be merged as defaults
  -h, --help           display help for command

License

MIT