You may have experienced this when using MongoDB in your Javascript or Typescript project.
The cause may be different so I will write many solution. Please add yours too.
The #1 Solution
Remove the
; at the end of your environment variable line if it exists.In my project, I just copied and pasted the value somewhere, and it apparently has
; at the end of the MONGODB_URI environment variable value like this:MONGODB_URL="mongodb://<the rest of uri>"; <-- this ; is the cause
I found the solution here.
https://www.mongodb.com/community/forums/t/unable-to-connect-db-because-of-throw-new-mongoparseerror-invalid-scheme-expected-connection-string-to-start-with-mongodb-or-mongodb-srv/176629/6
The #2 Solution
Please add comment for your solution to help other’s! 🙌
Is it the only solution?
Well, that’s what happened in my case. If you have another case and would like to share it with the community, please add a comment.
Thank you!