This is a package about injecting data to process.env object from a .env file, made this package reason is dotenv package is unstable.
npm i @mazp/dotenv
yarn add @mazp/dotenv
dotenv test.env rimraf dist
if you don't pass a .env file, default use that named config.env file in the root dir, that you can direct use command like follow:
dotenv rimraf dist
dotenv NODE_ENV=development rimraf dist
interface DotenvOption {
path?: string | string[];
command?: string[];
}
declare function dotenv(option: DotenvOption): void;
you can use this API, pass the path parameter inject data to process.env, path is a .env file location, if you do not pass, default use that named config.env file in the root dir. The path parameter is a relative root dir, so you maybe use a path or url module to load the correct path.
// ESM
import dotenv from "@mazp/dotenv";
dotenv({});
// CJS
let dotenv = require("@mazp/dotenv");
dotenv({ path: "test.env" });