next-env-cmd
v0.3.0
Published
Load .env files using @next/env module
Downloads
19
Readme
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