cross-env

Cross-platform environment variable setter for npm scripts. Allows setting environment variables in package.json scripts that work consistently on Unix (macOS, Linux) and Windows. On Unix, 'NODE_ENV=production node app.js' works natively; on Windows it doesn't. cross-env solves this: 'cross-env NODE_ENV=production node app.js' works on all platforms. Created by Kent C. Dodds. Now in maintenance mode — covered by native solutions on modern platforms.

Evaluated Mar 06, 2026 (0d ago) v7.x
Homepage ↗ Repo ↗ Developer Tools cross-platform environment-variables windows node npm-scripts cli utilities
⚙ Agent Friendliness
71
/ 100
Can an agent use this?
🔒 Security
95
/ 100
Is it safe for agents?
⚡ Reliability
97
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
95
Error Messages
88
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
92
Secret Handling
80

Env var injection — don't use for secrets in scripts visible in git history. Local-only execution. No network surface.

⚡ Reliability

Uptime/SLA
98
Version Stability
98
Breaking Changes
98
Error Recovery
95
AF Security Reliability

Best When

You have a Node.js project with developers on both Windows and Unix, and npm scripts that set environment variables.

Avoid When

Your team is Unix-only, or you're on Node.js 20+ where native cross-platform env var support has improved, or you use a package manager (Bun) with built-in support.

Use Cases

  • Set NODE_ENV=production/development/test in npm scripts that must run on both Windows and Unix developer machines
  • Pass environment variables to build scripts (webpack, Vite, rollup) cross-platform without shell-specific syntax
  • Standardize environment variable syntax in package.json scripts across Windows and Unix dev teams
  • Set multiple environment variables for test configurations in cross-platform test runner scripts
  • Configure environment-specific settings in npm run scripts without PowerShell or bash conditionals

Not For

  • Secret management — don't put sensitive values in package.json scripts; use .env files with dotenv
  • Production environment configuration — use platform-specific env var injection (Docker ENV, Heroku Config Vars)
  • Runtime environment detection — use process.env directly in code for reading env vars

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No authentication — CLI utility.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Fully free, MIT licensed.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • cross-env is now in maintenance mode — for new projects, consider npm v7+ workspaces or platform-native solutions; cross-env still works but won't get new features
  • Values with spaces require quotes: cross-env MY_VAR='hello world' node app.js — quoting syntax varies by shell; test on target platforms
  • cross-env doesn't handle .env files — it only sets variables from command-line arguments; use dotenv for .env file loading
  • Don't put secrets in package.json scripts with cross-env — package.json is committed to git; use dotenv or CI/CD secrets for sensitive values
  • Windows PowerShell and cmd.exe both supported — cross-env normalizes the syntax so the underlying shell doesn't matter
  • cross-env-shell variant available for scripts that need shell processing (glob expansion, pipes) — regular cross-env spawns command directly without shell

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for cross-env.

$99

Scores are editorial opinions as of 2026-03-06.

5208
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered