All articles
cli

Inline environment variables in CLI

Share this article

Share on LinkedIn Share on X (formerly Twitter)

While running npm scripts there are certain situations where you need to set an environment variable for just that particular instance of the command. It is mostly for temporary purposes.

Windows (cmd.exe)

set "BROWSER=none" && npm start

Windows (Powershell)

($env:BROWSER = "none") -and (npm start)

Linux, macOS (Bash)

BROWSER=none npm start

For permanent cases use .env files

Reference

This post is inspired from Create React App's docs


Comments