Set value of a Variable in .env file from .sh file in Nestjs project

32 Views Asked by At

I am attempting to set the value of MONGOOSE_URI (in .env file) by configuring its value using a .sh script.

setup.sh export URL="mongodb+srv.........."

.env MONGOOSE_URI=$URL

For starting the script, I execute: source setup.sh && nest start

Upon checking the console, process.env.MONGOOSE_URI returns $URL instead of the actual value.

I tried manually running the .sh file with echo, and it executed correctly. This method has been working in a Next.js project.

0

There are 0 best solutions below