This script generates a basic MERN stack file structure, including a React app generated using create-react-app
in the client
directory and an Express server in the server
directory with Mongoose for MongoDB integration.
To use this script, run the following command in your terminal:
sh mern_structure_generator.sh <main_file_name> [<directory_path>]
<main_file_name>
: Required argument. The name of your main file. This will be used as the name of your project directory and also as the name of the MongoDB database.[<directory_path>]
: Optional argument. The path where the project directory will be created. If not provided, the project directory will be created in the current directory. If the provided directory does not exist, the project directory will be created in the current directory.
Examples:
sh mern_structure_generator.sh myapp # Creates the directory 'myapp' in the current directory
sh mern_structure_generator.sh myapp /path/to/directory # Creates the directory 'myapp' in the '/path/to/directory' directory
After running the script and entering the created directory, you can run the following command in the main directory to start the client and server:
npm start
This will create two terminals, one for the client and one for the server.
This script was created by Bruno Vidigal.