phongduybui / fashion-shop

Fashion Shop - MERN
https://fashion-shopp.vercel.app
7 stars 3 forks source link

missing env file? #7

Open MuhaAllAmeen opened 2 years ago

MuhaAllAmeen commented 2 years ago

Hi I get the error "Error: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string." while trying to npm start the fashion shop 2.0 folder.

phongduybui commented 2 years ago

Hi, thank you for let me know your issue. The issue you meet because you missing define your .env file in your working repo. Because security issue so i dont upload .env file to public repo. However, i can give you sample for that

ADMIN_PASSWORD=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
CLOUDINARY_NAME=
JWT_SECRET=
MONGO_URI=
NODE_ENV=
PAYPAL_CLIENT_ID=
PORT=

In this project, i am using Mongo Atlas for database management, so all you need to fix this error is replace your MONGO_URI

Example format: mongodb+srv://<YourAccount>:<YourPassword>@<YourCluster>.xqtd0.mongodb.net/<YourCollection>?retryWrites=true&w=majority

Reference: https://www.mongodb.com/basics/mongodb-atlas-tutorial#:~:text=Creating%20a%20MongoDB%20Atlas%20Account&text=In%20order%20to%20create%20an,register%20using%20your%20email%20address.

MuhaAllAmeen commented 2 years ago

Hi, I have given the appropriate uri, port and the node_env but I just can't seem to run the program. I move to the main directory and type in npm start and still get the same error. Am I missing something? Your help would be greatly appreciated.

phongduybui commented 2 years ago

Can u give me screenshot of error, error message description, your .env file or something related about that?

MuhaAllAmeen commented 2 years ago

image

phongduybui commented 2 years ago

I have found your problem. Please move your .env file to one outer folder, same level with backend folder, not inner backend folder

MuhaAllAmeen commented 2 years ago

Thank you so much for your help. The server now seems to be working in development mode but the webpage does not seem to open on npm start. Am I missing something?

MuhaAllAmeen commented 2 years ago

image This is what I get on opening local host 5000. How do I get to the web page itself?

phongduybui commented 2 years ago

You are welcome, to run webpage, all steps u need is: