DEV Community

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

Posted on • Edited on

3

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

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 in two ways:

  1. nest start --exec "node --env-file=.env"
  2. For NestJS v11 or above: nest start --env-file .env

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay