This project is a MERN stack application featuring a React frontend and an Express backend. It utilizes Vite
for frontend development and nodemon
for backend development. This README provides instructions on how to set up, run, and deploy the project.
- Installation
- Running the Project
- File Structure
- Environment Variables
- Common Issues
- Deployment
- Contributing
- License
-
Clone the Repository
git clone <repository-url> cd <repository-directory>
-
Install Dependencies
Install the dependencies for both the backend and frontend:
npm install npm install --prefix frontend
To start the project in development mode:
npm run dev
This will:
- Set
NODE_ENV
todevelopment
. - Use
nodemon
to automatically restart the server on code changes.
To build the frontend and install necessary dependencies:
npm run build
This will:
- Install backend dependencies.
- Install frontend dependencies and build the frontend project.
To start the project in production mode:
npm run start
This will:
- Set
NODE_ENV
toproduction
. - Run the backend server.
frontend/
- Contains the frontend source code and build configuration.backend/
- Contains the backend source code and configuration.package.json
- Contains project metadata and scripts.
Create a .env
file in the backend
directory with the following variables:
PORT=5000
MONGO_URL=<your-mongodb-connection-string>
Replace <your-mongodb-connection-string>
with your actual MongoDB connection string.
-
ENOENT Error: If you encounter an
ENOENT
error, ensure thefrontend/dist
directory exists and contains theindex.html
file. Adjust paths inbackend/server.js
if necessary. -
Module Not Found: Ensure all dependencies are installed correctly by running
npm install
in the root directory.
For deployment, ensure the frontend/dist
directory is correctly included and accessible by the backend server. Adjust paths in backend/server.js
as needed based on your deployment environment.
Feel free to open issues or submit pull requests if you find any bugs or have improvements.
To contribute, please fork the repository, make your changes, and submit a pull request with a clear description of the changes and the reason for them.