Tip: npm scripts can reference env vars as variables: "start": "node...


Tip: npm scripts can reference env vars as variables:

"start": "node ./hello.js $PORT"

The $PORT above reads the PORT env variable.

You can pass env vars on the command line too:

PORT=3000 npm start
👆 runs the "start" script above like this:

node ./hello.js 3000
Note: If your team isn't all using the same OS, use cross-env for cross-platform friendly environment variables.

https://www.npmjs.com/package/cross-env

View original on X