On my old pc, let’s call it PC-1, I have a nest js backend application and environmental files are working properly when I run npm run start:dev . I’m using nest js built-in ConfigService/ConfigModule to read the environtmental variables from .env file. However, when I transfer to other new pc(PC-2) and clone the files, then the below error exist.
MongooseError: The
uri
parameter toopenUri()
must be a string, got “undefined”. Make sure the first parameter tomongoose.connect()
ormongoose.createConnection()
is a string.
Obviously, my .env files is not read. That is why it returns undefined.
Alternatively when i install dotenv and call the config function, then it will work smoothly. But Im wondering on my previous computer I didn’t install dotenv package and it works smootly because under the hood, Nest JS ConfigService/ConfigModule uses dotenv.
Please help!
#nestjs