DEV Community

Discussion on: Build a CLI with Node.js

Collapse
 
uguremirmustafa profile image
uguremirmustafa

Thanks for the post! I would like to use .env variables in my cli app but when I npm link it, it cannot reach my .env files from any other directories. Do you have any advice solving this problem?

Collapse
 
rushankhan1 profile image
Rushan Khan • Edited

Thanks for reading!
Have you tried setting the exact path of your .env file in the .env config as so:

require('dotenv').config({ path: '/absolute/path/to/your/.env/file' })
Enter fullscreen mode Exit fullscreen mode