@dotenvx/primitives

中文文档
4.4.0发布于 2026/11/07BSD-3-ClauseCommonJS零依赖近 30 天下载 4846.5万

a secure dotenv–from the creator of dotenv

原始使用文档
文档目录36 节
  1. Installation
  2. API
  3. check(policy, env)
  4. decrypt
  5. derive
  6. encrypt
  7. encrypted
  8. evaluate
  9. expand
  10. injectsummary
  11. keypair
  12. keyring
  13. keyringSync
  14. match
  15. parse
  16. parseSync
  17. parsearrays
  18. parsearraysSync
  19. parsedotenvxfile(source, file = '.env')
  20. policy(source, file = '.env')
  21. storagepolicy(source, file = '.env')
  22. storagecheck(policy, scanned)
  23. profile(source, options = {})
  24. publickeys
  25. redact(text, secrets)
  26. remove
  27. scan
  28. sealed(src, storagePolicy?)
  29. upsert
  30. Compatibility
  31. Publishing
  32. Third Party Notices
  33. eciesjs
  34. @ecies/ciphers
  35. @noble/curves and @noble/hashes
  36. @noble/ciphers

@dotenvx/primitives

Official Node.js implementation of dotenvx primitives.

It provides dotenv parsing, expansion, command evaluation, secp256k1 ECIES encryption and decryption, keyrings, scanning, matching, sealed detection, and dotenv source updates.

Installation

npm install @dotenvx/primitives

Create a .env file:

HELLO=World

Encrypt it:

$ dotenvx encrypt

Read and parse it in index.cjs, then print each key and value:

// index.cjs
const fs = require('node:fs')
const { parseSync } = require('@dotenvx/primitives')

const path = '.env'
const src = fs.readFileSync(path, 'utf8')
const parsed = parseSync(src)

for (const [key, value] of Object.entries(parsed.parsed)) {
  console.log(`${key}=${value}`)
}

Then run it.

$ node index.cjs
HELLO=World

API

One Dotenvxfile source produces two policies for different stages:

GenerateValidateRules per keyValues supplied to the checker
policycheckenv and stdoutFinal resolved environment strings
storagepolicystoragecheckstorage onlyOriginal stored strings, before decryption

Both policy generators work in memory. The caller supplies the source text and values; these primitives do not read files or load the shell environment.

Node.jsPurpose
checkCheck a compiled Dotenvxfile policy against final environment values
decryptDecrypt an encrypted dotenvx value
deriveDerive a compressed public key from a private key
encryptEncrypt a value for a public key
encryptedDetect the encrypted: prefix
evaluateEvaluate $(command) substitutions
expandExpand environment-variable expressions
keypairGenerate or restore a secp256k1 keypair
keyringBuild a public-to-private-key map
keyringSyncBuild a keyring synchronously
matchCreate a key-pattern matcher
parseParse, expand, decrypt, and classify dotenv strings
parseSyncParse dotenv strings synchronously
parsearraysParse dotenv values while preserving duplicate assignments
parsearraysSyncParse dotenv arrays synchronously
parsedotenvxfileReturn declared keys with empty string values from Dotenvxfile source
parsedotenvxfileSyncSynchronously return declared keys with empty string values
policyCompile Dotenvxfile text or a Buffer into a resolved policy object
profileSelect a comma-separated file list from Dotenvxfile profiles and caller inputs
publickeysExtract dotenv public-key metadata
redactReplace secret strings with redacted markers
removeRemove dotenv assignments by key
scanScan dotenv assignments, duplicates, and comments
sealedCheck whether values are encrypted, blank, or secret references
storagecheckValidate original stored strings against a storage policy
storagepolicyCompile storage rules from Dotenvxfile source for one file
upsertInsert or replace dotenv assignments

check(policy, env)

Validates the final environment object env and returns { checked, errors }. Returned values follow their named redaction rules, falling back to keys["*"].stdout.redacted for undeclared keys; inputs are unchanged. Supplied undeclared keys also use the wildcard environment validation rules and diagnostic strictness. Missing undeclared keys produce no diagnostics. Errors include the key, code, rule, message, and strict flag.

check(policy('redacted true\nenv "TOKEN"'), { TOKEN: 'abc123' })
// { checked: { TOKEN: '[REDACTED]' }, errors: [] }

decrypt

Decrypts an encrypted: value using a hex-encoded private key. Plain values are returned unchanged.

const { decrypt, encrypt, keypair } = require('@dotenvx/primitives')

const { privateKey, publicKey } = keypair()
const encryptedValue = encrypt(publicKey, 'World')
const plaintext = decrypt(privateKey, encryptedValue)
console.log(plaintext)
// World

Errors expose stable dotenvx codes:

const { decrypt } = require('@dotenvx/primitives')

try {
  decrypt('', 'encrypted:abc123')
} catch (error) {
  console.log(error.code)
  // MISSING_PRIVATE_KEY
}

Pass { prefix: false } as the third argument to decrypt base64 ciphertext that does not include the encrypted: prefix.

derive

Derives the compressed secp256k1 public key for a private key.

const { derive, keypair } = require('@dotenvx/primitives')

const { privateKey, publicKey } = keypair()
console.log(derive(privateKey) === publicKey)
// true

encrypt

Encrypts a UTF-8 value using dotenvx-compatible ECIES and returns an encrypted:-prefixed value.

const { encrypt, keypair } = require('@dotenvx/primitives')

const { publicKey } = keypair()
const encryptedValue = encrypt(publicKey, 'World')
console.log(encryptedValue.startsWith('encrypted:'))
// true

Encryption is randomized, so encrypting the same value twice produces different ciphertexts.

encrypted

Checks whether a value begins with the case-sensitive encrypted: prefix. The prefix is also available as encrypted.PREFIX.

const { encrypted } = require('@dotenvx/primitives')

console.log(encrypted.PREFIX)
// encrypted:
console.log(encrypted('encrypted:abc123'))
// true
console.log(encrypted('World'))
// false

evaluate

Evaluates shell command substitutions and removes trailing newlines from command output. The example below uses a POSIX shell command.

const { evaluate } = require('@dotenvx/primitives')

const value = evaluate('HELLO=$(printf World)', {})
console.log(value)
// HELLO=World

Pass an options object, using {} for defaults:

OptionDefaultPurpose
processEnvprocess.envEnvironment values supplied to the command
runningParsed{}Previously parsed values; override processEnv for the command

Failed commands throw an error with code COMMAND_SUBSTITUTION_FAILED.

expand

Expands $NAME, ${NAME}, default-value expressions, and alternate-value expressions.

const { expand } = require('@dotenvx/primitives')

const value = expand('postgres://${USER}:$PASS@localhost', {
  processEnv: { USER: 'scott', PASS: 'secret' }
})
console.log(value)
// postgres://scott:secret@localhost

Supported operators:

  • ${NAME:-fallback} uses the fallback when missing or empty.
  • ${NAME-fallback} uses the fallback when missing.
  • ${NAME:+alternate} uses the alternate when present and non-empty.
  • ${NAME+alternate} uses the alternate when present.

Pass an options object, using {} for defaults:

OptionDefaultPurpose
processEnvprocess.envExisting environment values
runningParsed{}Progressively parsed values
overloadfalseGive runningParsed precedence over processEnv
literals{}Literal values whose expansion expressions should not be expanded again

injectsummary

injectsummary(count, files = []) formats the shared injection summary without logging, inspecting environment values, or adding ANSI colors. Callers decide when and where to print it, and apply their own quiet settings.

const { injectsummary } = require('@dotenvx/primitives')
injectsummary(2, ['.env']) // ⟐ injected env (2) from .env

Files may also be public metadata objects with filepath, publicKeys, and keySources (public key → provider identifier). This includes short codes and unique custody labels, for example:

injectsummary(3, [{
  filepath: '.env',
  publicKeys: ['031f20abc'],
  keySources: { '031f20abc': 'armor' }
}]) // ⟐ injected env (3) from .env (031 F20) via Armor ⛨

injectsummary.sources(files) returns { files, suffix } for other command summaries, so encryption and decryption use the same labels and short codes. Only pass public metadata, never private keys or environment values.

keypair

Generates a new keypair or restores one from an existing private key.

const { keypair } = require('@dotenvx/primitives')

const generated = keypair()
const restored = keypair(generated.privateKey)
console.log(generated.publicKey === restored.publicKey)
// true

The returned object contains privateKey and publicKey hex strings.

keyring

Builds an object whose keys are public keys and whose values are their matching private keys.

const { keyring, keypair } = require('@dotenvx/primitives')

const { privateKey, publicKey } = keypair()
const ring = await keyring({
  processEnv: { DOTENV_PRIVATE_KEY: privateKey }
})
console.log(ring[publicKey] === privateKey)
// true

By default, keyring() reads .env.keys from the current working directory and keys from process.env. Missing or unreadable key files are silently ignored. Set fk to override the paths, or to [] to disable file reads.

OptionDefaultPurpose
processEnvprocess.envEnvironment containing DOTENV_PRIVATE_KEY* and DOTENV_PUBLIC_KEY* entries
ring{}Existing public-to-private-key object, populated in place
fk'.env.keys'Key-file path or array of paths
providerNoneFunction called with a public key when its private key is missing; returns a keyring object or a promise for one

Private-key assignments in key files may be repeated or comma-separated. Invalid private keys are ignored. Public keys without a matching private key remain in the ring with an empty value.

keyringSync

Builds a keyring synchronously with the same options. A supplied provider must return an object synchronously.

const { keyringSync, keypair } = require('@dotenvx/primitives')

const { privateKey, publicKey } = keypair()
const ring = keyringSync({ processEnv: { DOTENV_PRIVATE_KEY: privateKey } })
console.log(ring[publicKey] === privateKey)
// true

Also available as keyring.sync(options).

match

Creates a matcher supporting glob patterns, including * and ?, plus ignored patterns. Uses picomatch patterns and options.

const { match } = require('@dotenvx/primitives')

const isAllowed = match(['DOTENV_*'], { ignore: ['DOTENV_PRIVATE_*'] })
console.log(isAllowed('DOTENV_PUBLIC_KEY'))
// true
console.log(isAllowed('DOTENV_PRIVATE_KEY'))
// false

parse

Parses dotenv source while applying expansion, overload precedence, selective decryption, and injected-versus-existing classification.

const { parse } = require('@dotenvx/primitives')

const result = await parse('A=file\nB=$A\nHELLO=World', { processEnv: {} })
console.log(result.parsed.B)
// file

for (const [key, value] of Object.entries(result.parsed)) {
  console.log(`${key}=${value}`)
}

parse() automatically calls keyring(), reading .env.keys from the current working directory by default. Missing or unreadable key files are silently ignored. Override fk to use other paths, or supply [] to disable file reads. The caller still supplies the dotenv source string; parse() does not read .env or write the returned values into process.env.

OptionDefaultPurpose
processEnvprocess.envExisting environment values for precedence, expansion, and key discovery
overloadfalseLet source values override existing environment values
ikAll keysKey pattern or array of patterns to decrypt
ekNo exclusionsKey pattern or array of patterns to exclude from decryption
fk'.env.keys'Key-file path or array of paths
providerNoneResolve missing private keys; same callback as keyring()

Exclusion patterns win over inclusion patterns. These patterns control decryption; excluded keys remain in the parsed output.

The result contains:

FieldContents
parsedAll parsed key/value pairs
injectedValues classified for injection, including decrypted pre-existing ciphertext
existedValues preserved from the supplied environment
errorsParsing/decryption error objects with code and message

Values in all three objects are strings. Repeated keys keep their last processed value. Check errors for unresolved encrypted values. Exceptions from a key provider can reject the promise.

parseSync

Parses dotenv source synchronously with the same options and result shape. A supplied provider must be synchronous.

const { parseSync } = require('@dotenvx/primitives')

const result = parseSync('HELLO=World', { processEnv: {} })
console.log(result.parsed.HELLO)
// World

Also available as parse.sync(source, options).

parsearrays

Use parsearrays(source, options) to preserve duplicate assignments as arrays. It accepts the same options as parse(). All three objects (parsed, injected, and existed) contain arrays, even for keys with a single assignment. parse() keeps the last value instead.

const { parsearrays } = require('@dotenvx/primitives')

const result = await parsearrays('HELLO=World\nHELLO=Node', { processEnv: {} })
console.log(result.parsed.HELLO)
// ['World', 'Node']

Both functions automatically build a keyring and share expansion, decryption, and precedence behavior. Exclusion patterns win over inclusion patterns.

Migration: replace parse(source, { array: true }) with parsearrays(source). Remove array from the options; it no longer changes the output type.

parsearraysSync

Parses arrays synchronously with the same options and result shape as parsearrays(). A supplied provider must be synchronous.

const { parsearraysSync } = require('@dotenvx/primitives')

const result = parsearraysSync('HELLO=World\nHELLO=Node', { processEnv: {} })
console.log(result.parsed.HELLO)
// ['World', 'Node']

Also available as parsearrays.sync(source, options).

parsedotenvxfile(source, file = '.env')

Also available synchronously as parsedotenvxfile.sync(source, file) or parsedotenvxfileSync(source, file).

Returns declared keys with empty string values for the selected files.

await parsedotenvxfile('env "PORT"\nenv "TOKEN"')
// { PORT: '', TOKEN: '' }

policy(source, file = '.env')

Compiles Dotenvxfile text or a Buffer into { keys: { ... } }. Each key has env validation rules and stdout redaction rules. Storage settings are omitted. For comma-separated filenames, the first file wins explicit rules. Compilation works in memory; the caller reads files and loads environment values.

const rules = policy('env "TOKEN", required: true, redacted: true')
// rules.keys.TOKEN:
// { env: { type: 'string', required: true, strict: false },
//   stdout: { redacted: true } }

The reserved keys["*"] entry contains defaults for undeclared keys.

The same source can generate both policies:

const source = 'storage "encrypted"\nenv "TOKEN", required: true, redacted: true'
const envRules = policy(source, '.env.production')
const storageRules = storagepolicy(source, '.env.production')

check(envRules, { TOKEN: 'resolved-secret' })
// { checked: { TOKEN: '[REDACTED]' }, errors: [] }
storagecheck(storageRules, { TOKEN: ['encrypted:example'] })
// { checked: { TOKEN: ['encrypted:example'] }, errors: [] }

storagepolicy(source, file = '.env')

Compiles the same source for exactly one filename. Each key contains only storage rules: type (any, encrypted, or plaintext), required, and strict. Type defaults to any. Required and strict follow the same resolution as policy: per-key override, selected file setting, root setting, then false. There are no stdout/redaction settings in this policy.

const rules = storagepolicy('storage "encrypted"\nenv "PORT", storage: "plaintext"', '.env.production')
storagecheck(rules, { PORT: ['3000'], TOKEN: ['encrypted:example'] })

Pass original stored strings to storagecheck, before decryption. Encryption checks recognize the encrypted: prefix; they do not authenticate ciphertext.

storagecheck(policy, scanned)

Checks original stored strings against storagepolicy rules and returns checked and errors. No stdout redaction is applied. Use check with policy for resolved environment validation and redaction.

profile(source, options = {})

Resolves Dotenvxfile profiles to comma-separated filenames. Accepts f, profile, processEnv, and environmentKeys options. processEnv defaults to process.env; pass {} to ignore the process environment. Explicit files win over profile names; without a selection, uses the development profile or .env.

profile('profile "production", files: [".env.production"]', { profile: 'production' })
// '.env.production'

publickeys

Extracts the final value of every DOTENV_PUBLIC_KEY* assignment while preserving key order.

const { publickeys } = require('@dotenvx/primitives')

const keys = publickeys('DOTENV_PUBLIC_KEY=public-a\nDOTENV_PUBLIC_KEY_PRODUCTION=public-b')
console.log(keys)
// ['public-a', 'public-b']

redact(text, secrets)

Replaces literal secret strings with [REDACTED], including overlapping matches.

redact('token=abc123', ['abc123']) // 'token=[REDACTED]'

remove

Removes every assignment for the given key. It preserves surrounding lines, comments, multiline values for other keys, and CRLF line endings. If the key is missing, the source is returned unchanged.

const { remove } = require('@dotenvx/primitives')

const updated = remove('HELLO=one\nFOO=bar\nHELLO=two\n', 'HELLO')
console.log(updated === 'FOO=bar\n')
// true

scan

Scans dotenv assignments without applying expansion or decryption. Duplicate values and their comments are preserved in source order.

const { scan } = require('@dotenvx/primitives')

const result = scan('HELLO=first\nHELLO=second # optional')
console.log(result.scanned.HELLO)
// ['first', 'second']
console.log(result.comments.HELLO)
// [undefined, 'optional']
OptionDefaultPurpose
ikAll keysKey pattern or array of patterns to include
ekNo exclusionsKey pattern or array of patterns to exclude
expandDoubleQuotedNewlinestrueDecode escaped newlines, carriage returns, and tabs in double-quoted values
convertWindowsNewlinestrueNormalize CRLF and CR line endings to LF

An optional transform receives { name, value, quote, comment } for each assignment. Its returned value is stored in the corresponding array:

const { scan } = require('@dotenvx/primitives')

const result = scan('HELLO=World', ({ value }) => value.toUpperCase())
console.log(result.scanned.HELLO)
// ['WORLD']

With options, pass the transform as the third argument: scan(source, options, transform).

sealed(src, storagePolicy?)

Returns true when every non-metadata value is encrypted, empty or whitespace-only, or begins with op:// (1Password) or bw:// (Bitwarden Password Manager). DOTENV_PUBLIC_KEY* and *_PLAIN values are allowed to remain plaintext. Empty source is considered sealed. Every duplicate assignment is checked. An optional resolved storagepolicy() allows plaintext keys. Explicit encrypted rules override the _PLAIN suffix; any uses the suffix convention. Existing ciphertext remains accepted even when the policy permits plaintext. Secret references are recognized by their case-sensitive prefix; they are not resolved or validated against the provider. Other URLs, variable references, and command substitutions are not exempt.

const { sealed } = require('@dotenvx/primitives')

console.log(sealed('HELLO=encrypted:abc123'))
// true
console.log(sealed('HELLO=World'))
// false

upsert

Inserts a missing assignment or replaces all occurrences of an existing key. It preserves existing quote style, export prefixes, multiline values, and CRLF line endings.

const { upsert } = require('@dotenvx/primitives')

const updated = upsert('HELLO=one\nHELLO=two', 'HELLO', ['uno', 'dos'])
console.log(updated)
// HELLO=uno
// HELLO=dos

A string replacement applies to every occurrence. For per-occurrence changes, supply an array with one replacement for each existing assignment. For a new key, supply a string; the inserted assignment is double-quoted.

Compatibility

The implementation is tested against private Node.js conformance tests. The Rust implementation provides the corresponding primitives with Rust-native types and naming, including policy, storagepolicy, profile, check, and redact with the same Dotenvxfile defaults and precedence rules.

Publishing

Publishing is performed manually from this directory. Keep the npm and Rust versions matched, following DEVELOPMENT.md, then run:

npm run standard
npm run build
npm pack --dry-run
npm publish

Third Party Notices

This package bundles portions of the following MIT-licensed packages:

  • eciesjs
  • @ecies/ciphers
  • @noble/curves
  • @noble/hashes
  • @noble/ciphers

eciesjs

MIT License

Copyright (c) 2019-2026 Weiliang Li

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ecies/ciphers

MIT License

Copyright (c) 2019-2026 Weiliang Li

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@noble/curves and @noble/hashes

The MIT License (MIT)

Copyright (c) 2022 Paul Miller (https://paulmillr.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@noble/ciphers

The MIT License (MIT)

Copyright (c) 2022 Paul Miller (https://paulmillr.com) Copyright (c) 2016 Thomas Pornin [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

版本与发布记录

@dotenvx/primitives 共发布 58 个版本,首次发布于 2026/06/20;过去 12 个月发布了 58 个版本。

版本发布日期距今
4.4.0latest2026/11/076 天前
4.3.02026/10/2915 天前
4.2.32026/10/2915 天前
4.2.22026/10/2915 天前
4.2.12026/10/2915 天前
4.2.02026/10/2915 天前

关于 @dotenvx/primitives 的常见问题

@dotenvx/primitives 是什么?

a secure dotenv–from the creator of dotenv

如何安装 @dotenvx/primitives?

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

@dotenvx/primitives 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dotenvx__primitives 是否存在。

@dotenvx/primitives 支持 ESM 还是 CommonJS?

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

@dotenvx/primitives 可以商用吗?

@dotenvx/primitives 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@dotenvx/primitives 的下载量有多少?

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

@dotenvx/primitives 还在维护吗?

最新版本 4.4.0 发布于 2026/11/07(6 天前);至今共发布 58 个版本,其中过去 12 个月发布了 58 个;首次发布于 2026/06/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。