node -r dotenv/config script.js

Category: Node.js & npm/yarn

node -r dotenv/config script.js

Pre-require the dotenv package to load .env variables before your script runs

Pre-requires (loads before the main script) the dotenv package so .env variables are available from the very first line of your code.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.