Socket
Book a DemoInstallSign in
Socket

create-mern-cli

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-mern-cli

A powerful CLI tool to effortlessly generate a MERN stack project (MongoDB, Express, React, Node.js) with Vite/Webpack, Tailwind/Bootstrap, and backend frameworks like Express.js. Ideal for developers looking to bootstrap full-stack JavaScript projects wi

latest
Source
npmnpm
Version
1.1.4
Version published
Maintainers
2
Created
Source

Create MERN CLI ๐Ÿš€

A powerful CLI tool to scaffold full-stack MERN (MongoDB, Express, React, Node.js) applications with robust error handling and automatic cleanup.

MERN Stack Node Version License

Features โœจ

  • Interactive Setup: Guided CLI prompts for project configuration
  • Automatic Error Recovery: Comprehensive cleanup on setup failures
  • Modern Frontend: Choose between Vite or Webpack
  • Backend Options: Mongoose (MongoDB) or Sequelize (SQL) support
  • Testing Ready: Optional Jest/Mocha testing setup
  • Production-Ready: Includes essential middleware and security best practices

Installation ๐Ÿ“ฆ

npx create-mern-cli@latest

For global installation:

npm install -g create-mern-cli
create-mern-cli

What's New in v2.0 ๐Ÿ†•

  • Automatic Cleanup: If setup fails, all created files are removed
  • Enhanced Error Handling: Detailed error messages with recovery suggestions
  • Optimized Dependencies: Faster installation with only essential packages
  • Windows Support: Improved compatibility for Windows systems

Usage ๐Ÿ› ๏ธ

Run the CLI and follow the interactive prompts:

npx create-mern-cli

You'll be asked to configure:

  • Project name
  • Frontend bundler (Vite/Webpack)
  • CSS framework (Tailwind/Bootstrap/None)
  • Backend ORM (Mongoose/Sequelize/None)
  • Testing setup (Jest/Mocha)

Project Structure ๐Ÿ“‚

Your new project will include:

project-name/
โ”œโ”€โ”€ client/            # React frontend
โ”‚   โ”œโ”€โ”€ public/        # Static assets
โ”‚   โ”œโ”€โ”€ src/           # Application code
โ”‚   โ””โ”€โ”€ package.json   # Frontend dependencies
โ”‚
โ””โ”€โ”€ server/           # Node.js server
    โ”œโ”€โ”€ controllers/   # Business logic
    โ”œโ”€โ”€ routes/        # API endpoints  
    โ”œโ”€โ”€ models/        # Database models
    โ”œโ”€โ”€ .env           # Environment variables
    โ”œโ”€โ”€ index.js       # Server entry point
    โ””โ”€โ”€ package.json   # Backend dependencies

Error Recovery System โš ๏ธ

The CLI features robust error handling:

  • Automatic Rollback: If any step fails, all created files are deleted
  • Detailed Logging: Clear error messages with cleanup status
  • Safe Retry: Clean state allows restarting the setup

Example error scenario:

Error: Failed to install dependencies
๐Ÿงน Cleaning up created files and directories...
  - Deleted file: /projects/test-mern/backend/package.json
  - Deleted directory: /projects/test-mern/backend
โš ๏ธ Setup failed. All created files have been removed.

Getting Started ๐Ÿ

  • Start development servers:
cd your-project-name
cd client && npm run dev  # Frontend
cd server && npm run dev # Backend
  • Access your app at http://localhost:3000

Configuration โš™๏ธ

Essential Environment Variables

Backend .env template:

PORT=5000
NODE_ENV=development

# MongoDB (if using Mongoose)
MONGO_URI=mongodb://localhost:27017/yourdb

# SQL (if using Sequelize)
DB_NAME=yourdb
DB_USER=root
DB_PASSWORD=
DB_HOST=localhost

Customizing the Backend

The generated backend includes:

  • Express server with CORS and JSON middleware
  • Example CRUD routes/controllers
  • Error handling middleware
  • Nodemon for development

Deployment ๐Ÿš€

Frontend

cd client
npm run build  # Outputs to /dist

Backend

cd server
npm start     # Production mode

Recommended hosting:

  • Frontend: Vercel, Netlify, AWS S3
  • Backend: Railway, Heroku, AWS EC2

FAQ โ“

Q: What if installation gets interrupted?
A: The cleanup system will remove all partial files automatically.

Q: How do I add more backend routes?
A: Create new files in:

  • backend/routes/ for endpoints
  • backend/controllers/ for business logic

Q: Can I use TypeScript?
A: Yes! Select TypeScript when prompted during Vite setup.

Support ๐Ÿ›Ÿ

For issues, please:

  • Check error messages carefully
  • Clear node_modules and try again
  • Open a GitHub issue with:
    • Node.js version (node -v)
    • Exact error message
    • Steps to reproduce

Contributing ๐Ÿค

We welcome contributions! Please:

  • Fork the repository
  • Create a feature branch
  • Submit a pull request

License ๐Ÿ“„

MIT ยฉ Prashant Sharma and Vikas Tiwari

Thank You

Keywords

mern

FAQs

Package last updated on 08 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.