@dot/env

中文文档
0.1.5发布于 2024/05/16MPL-2.0TypeScriptCommonJS近 30 天下载 2451

Load environment variables from .env files

原始使用文档
文档目录4 节
  1. Requirements
  2. Install
  3. Usage
  4. Meta

@dot/env

Load environment variables from .env files.

This tiny package composes a few packages in order to load .env intelligently:

  • dotenv
  • dotenv-expand
  • find-up

Differences with dotenv:

  • Automatically expands variables such as ${NODE_ENV} within the .env files
  • Searches the immediate directory (current working directory) for an .env file, and if not found, continues to look in parent directories until a .env file is found, or .git is encountered.

Possible future features:

  • Composing multiple .env files
  • Extending .env files

Requirements

This package requires an Active LTS Node version (v18+).

Install

Using pnpm:

pnpm add @dot/env

Usage

Usage is straightforward:

import '@dot/env';

That's it. You're good to go.

Meta

CONTRIBUTING

LICENSE (Mozilla Public License)

版本与发布记录

@dot/env 共发布 6 个版本,首次发布于 2023/01/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.5latest2024/05/162 年前
0.1.42023/05/313 年前
0.1.32023/02/263 年前
0.1.22023/01/253 年前
0.1.12023/01/253 年前
0.1.02023/01/253 年前

关于 @dot/env 的常见问题

@dot/env 是什么?

Load environment variables from .env files

如何安装 @dot/env?

在项目目录运行 npm install @dot/env,或使用 pnpm add / yarn add / bun add。

@dot/env 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dot/env 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dot/env 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dot/env 可以商用吗?

@dot/env 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@dot/env 的下载量有多少?

根据 npm 官方下载统计,@dot/env 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,451 次,日均约 82 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dot/env 还在维护吗?

最新版本 0.1.5 发布于 2024/05/16(2 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/01/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。