DEV Community

Micael Levi L. C.
Micael Levi L. C.

Posted on

NestJS tip: how to use Node.js built-in .env file reader with NestJS CLI

for NestJS v8, v9 and v10

Starting from Node.js v20.6.0 you can read dot env files into the process.env object using the --env-file=path nodejs option.

If you're using NestJS's CLI (@nestjs/cli package) you can turn on that Node.js option as follows:

nest start --exec "node --env-file=.env"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)