1.0.1 ⢠Published 4 months ago
@devsuite/create-mern v1.0.1
create-mern
A powerful scaffolder for MERN stack projects with Vite + React frontend and Express + MongoDB backend.
Features
- š Fast Setup - Create full MERN stack projects in seconds
- ā” Vite + React - Modern frontend development with hot reload
- š ļø Express + MongoDB - Robust backend with Mongoose ODM
- š¦ Package Manager Choice - Support for npm and pnpm
- šļø Flexible Structure - Choose full stack, frontend only, or backend only
- š§ Pre-configured - CORS, environment variables, and development scripts included
Usage
npm create mern
or,
pnpm create mern
Follow the interactive prompts to: 1. Enter your project name 2. Choose project structure (Full MERN, Frontend only, or Backend only) 3. Select package manager (npm or pnpm)
Project Structure Options
1. Full MERN Stack
Creates a complete MERN application with separate frontend and backend directories:
my-project/
āāā frontend/ # React + Vite application
āāā backend/ # Express + MongoDB API
āāā package.json # Root package.json with scripts
āāā README.md # Project documentation
2. Frontend Only
Creates a React + Vite application:
my-project/
āāā src/ # React components
āāā public/ # Static assets
āāā package.json # Frontend dependencies
āāā vite.config.js # Vite configuration
3. Backend Only
Creates an Express + MongoDB API:
my-project/
āāā routes/ # API routes
āāā models/ # Mongoose models
āāā controllers/ # Route controllers
āāā config/ # Configuration files
āāā server.js # Main server file
āāā .env # Environment variables
āāā package.json # Backend dependencies
Generated Project Features
Frontend (React + Vite)
- ā” Vite for fast development and building
- š React Router for navigation
- š” Axios for HTTP requests
- šØ Modern React setup with JSX
Backend (Express + MongoDB)
- š Express.js server with CORS enabled
- šļø MongoDB connection with Mongoose
- š Environment variable configuration
- š Nodemon for development hot reload
- š Pre-configured API endpoints:
GET /api/health
- Health checkGET /api/welcome
- Welcome messageGET /api/users
- Sample users endpoint
Available Scripts (Full Stack)
# Install all dependencies
npm run install:dependencies
# Start frontend development server
npm run dev:frontend
# Start backend development server
npm run dev:backend
# Build for production
npm run build
Environment Variables
For backend projects, a .env
file is created with:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/your-project-name
NODE_ENV=development
Requirements
- Node.js >= 16.0.0
- MongoDB/Atlas (for backend/full stack projects)
Package Managers
Supports both npm and pnpm package managers. Choose your preferred one during project creation.
Development
To contribute to create-mern:
git clone https://github.com/kmdtaufik/create-mern.git
cd create-mern
npm install
License
MIT
Keywords
- MERN stack
- React
- Express
- MongoDB
- Vite
- Scaffolder
- Template
- Full-stack development
1.0.1
4 months ago