@Hung_Viet the error is indicating the connection string is not available (instead of being of type “string”, it’s of type “undefined”).
Given the code you’ve shared it’s likely the MONGO_URI
environment variable wasn’t made available to the Node.js process.
Either start your application by doing MONGO_URI="mongodb+srv://..." node server.js
, or ensure you export
the variable first (see Environment Variables in Windows/macOS/Linux)
1 Like