This script is a Node.js application designed to automate the setup of a basic MERN (MongoDB, Express.js, React.js, Node.js) stack project. It creates a directory structure, initializes a React frontend, and sets up an Express backend with necessary dependencies.
- Node.js installed on your system
-
Save the provided script as
main.jsin your project directory. -
Navigate to the directory where you saved the
main.jsscript using the terminal or command prompt. -
Run the script using Node.js:
node main.js
- The script sets up a React frontend in a
clientdirectory using Vite as a bundler and creates directories for components and pages. - An Express backend is initialized in a
serverdirectory, including necessary folders for routes, controllers, and models andmongoosepackage for MongoDB. - Frontend and backend packages are installed automatically using npm.
- Unnecessary boilerplate code in the React frontend (
App.jsx,index.css,App.css) are cleared to provide a clean starting point.
This script will automatically delete itself (main.js) after setting up the project.
Make sure to run this script only in the directory where you want to create your MERN project as it will delete itself after execution.