A fullstack webiste building with mern stack for a shipping company.
Prerequisites:
- Docker
docker compose up -dPrerequisites:
- Node.js and pnpm (or yarn)
- MongoDB Database
Open a terminal or command prompt and navigate to the root directory of the project using cd
Steps:
4. Install Client Dependencies:
- Navigate to the 'client' directory in your root folder.
- Run the following command in your terminal:
This will install all the necessary dependencies for your React application.
pnpm install
5. Build the Project:
- To run the react app:
pnpm run dev
1. Install Server Dependencies:
-
Navigate to the 'server' directory in your root folder.
-
Setting Up Environment Variables:
1. Create a new file named
.envin the root directory of your server folder './server'. This file will store your environment variables:- In your server folder, create a new file named
.env.
2. Add environment variables:
- Paste the following content into the
.envfile, replacing the placeholders with your actual values:
MONGO_URL=mongodb://localhost:27017/final_surf JWT_SECRET=YOUR_JWT_SECRET JWT_LIFETIME=30d NODE_ENV=production PORT=50003. Save and restart the server:
4. Make sure that the Mongo databases work on the outlet 27017 and if you want to adjust the location of the database, adjust the "MONGO_URL" variable in the file "server/.env"
- Save the
.envfile and restart your Node.js server. The environment variables should now be accessible in your code.
- In your server folder, create a new file named
-
Run the following command in your terminal:
pnpm install
This will install the required dependencies for your Node.js server.
2. Run the Server:
- Once the server dependencies are installed, start the server using the following command:
This will start your Node.js server, listening on the specified port (usually
pnpm start
5000by default, but check your.envfile for the exact port).
Important Notes:
- Environment Variables: Ensure you have set up your environment variables correctly as described in the previous guide.
- Database Connection: If your server uses a database (e.g., MongoDB), make sure it's running and properly configured.
- Other Dependencies: If your project has additional dependencies or configurations, follow the specific instructions provided in your project's documentation.
