npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ts-node-init

v1.1.3

Published

Bootstrap a fully-configured Node.js + TypeScript project with ESLint, Prettier, Jest, and ready-to-use npm scripts.

Readme

ts-node-init

A powerful CLI tool to bootstrap modern Node.js + TypeScript projects with Express.js and MongoDB support in seconds. Stop wasting time on configuration and start building features immediately.

✨ Features

  • 🚀 Express.js + MongoDB - Full-stack REST API setup with modular architecture
  • 📦 TypeScript - Preconfigured with strict mode and best practices
  • 🎨 Code Quality - ESLint + Prettier integration for consistent code
  • 🧪 Testing - Jest + ts-jest ready for TypeScript testing
  • 📁 Clean Architecture - Organized modular folder structure (controller, service, routes, model)
  • 🔧 Production Ready - Pino logger, error handling, and environment variables
  • 🗄️ Database - Mongoose models with TypeScript types
  • Dev Experience - Hot reload with ts-node-dev
  • 🛡️ Safe Operation - Prevents overwriting existing projects
  • 🎯 Interactive Setup - Choose only the features you need
  • 💨 Quick Mode - Skip prompts with -y flag

📦 Installation

Install globally via npm:

npm install -g ts-node-init

Or use directly with npx (no installation required):

npx ts-node-init my-project

🚀 Usage

Interactive Mode (Recommended)

ts-node-init my-project

You'll be asked to configure:

  • ✅ Express.js setup
  • ✅ MongoDB integration
  • ✅ Prettier formatting
  • ✅ ESLint linting
  • ✅ .gitignore file

Quick Mode

Skip all prompts and create a full-featured project:

ts-node-init my-project -y
# or
ts-node-init my-project --yes

This creates a project with all features enabled (Express + MongoDB + Prettier + ESLint).

Initialize in Current Directory

ts-node-init .

Sets up the project in your current folder. Aborts if package.json exists to prevent overwriting.

📁 Project Structure

Full Stack Setup (Express + MongoDB)

my-project/
├── config/
│   └── default.ts              # Environment configuration
├── src/
│   ├── index.ts                # Application entry point
│   ├── shared/
│   │   └── utils/
│   │       ├── server.ts       # Express app setup
│   │       ├── connect.ts      # MongoDB connection
│   │       └── logger.ts       # Pino logger
│   └── modules/
│       └── user/               # Example user module
│           ├── controller/
│           │   └── user.controller.ts
│           ├── service/
│           │   └── user.service.ts
│           ├── routes/
│           │   └── user.routes.ts
│           └── model/
│               └── user.model.ts
├── .env                        # Environment variables
├── .env.example                # Environment template
├── .gitignore
├── .prettierrc                 # Prettier config (optional)
├── .eslintrc.json             # ESLint config (optional)
├── package.json
├── tsconfig.json
└── jest.config.json

Basic Setup (Node.js only)

my-project/
├── src/
│   └── app.ts                  # Sample TypeScript file
├── package.json
├── tsconfig.json
└── jest.config.json

🛠️ Available Scripts

Once your project is created:

npm run dev             # Start development with hot reload
npm run build           # Compile TypeScript to JavaScript
npm start               # Run production build
npm test                # Run tests in watch mode
npm run test:coverage   # Run tests with coverage
npm run format          # Format code with Prettier (if enabled)
npm run format:check    # Check code formatting (if enabled)
npm run lint            # Lint code with ESLint (if enabled)
npm run lint:fix        # Auto-fix linting issues (if enabled)

🎯 Quick Start Examples

Create a REST API

# Create project with Express + MongoDB
npx ts-node-init my-api -y

# Navigate and configure
cd my-api

# Update MONGO_URI in .env file
# Then start development
npm run dev

Server runs at http://localhost:3000 with:

  • Health check: GET /health
  • User routes: GET /api/user

Create a Simple Node.js App

# Create project (choose 'n' for Express)
npx ts-node-init my-app

# Start coding
cd my-app
npm run dev

⚙️ Configuration Details

TypeScript (tsconfig.json)

  • Target: ES2020
  • Module: CommonJS
  • Module Resolution: Node
  • Strict mode: Enabled
  • Source folder: src/
  • Output folder: build/
  • JSON support: Enabled

Environment Variables (.env)

PORT=3000
NODE_ENV=development
MONGO_URI=mongodb://localhost:27017/your-database

Modular Architecture

Each module follows a clean separation of concerns:

  • Controller - Handles HTTP requests/responses
  • Service - Contains business logic
  • Routes - Defines API endpoints
  • Model - Mongoose schema and types

This structure makes it easy to:

  • Add new features as modules
  • Test components independently
  • Scale your application
  • Maintain clean code

📚 What Gets Installed

Production Dependencies

  • express - Web framework (if selected)
  • cors - CORS middleware (if Express selected)
  • mongoose - MongoDB ODM (if MongoDB selected)
  • dotenv - Environment variables
  • pino - Fast logger (if MongoDB selected)
  • pino-pretty - Pretty logs (if MongoDB selected)
  • dayjs - Date manipulation (if MongoDB selected)

Development Dependencies

  • typescript - TypeScript compiler
  • ts-node-dev - Development server with auto-reload
  • @types/node - Node.js type definitions
  • @types/express - Express type definitions (if selected)
  • @types/cors - CORS type definitions (if selected)
  • jest - Testing framework
  • ts-jest - TypeScript support for Jest
  • @types/jest - Jest type definitions
  • prettier - Code formatter (if selected)
  • eslint - Code linter (if selected)
  • @typescript-eslint/parser - TypeScript parser (if selected)
  • @typescript-eslint/eslint-plugin - TypeScript rules (if selected)

💡 Use Cases

Perfect for:

  • ✅ REST API development
  • ✅ Microservices architecture
  • ✅ Backend applications with MongoDB
  • ✅ Express.js projects
  • ✅ Full-stack applications
  • ✅ CLI tools and scripts
  • ✅ TypeScript learning projects
  • ✅ Teams wanting consistent structure
  • ✅ Rapid prototyping
  • ✅ Hackathons and MVPs

🔧 Advanced Usage

Adding New Modules

Follow the existing pattern to add new modules:

mkdir -p src/modules/posts/{controller,service,routes,model}

Then create your controller, service, routes, and model files following the user module pattern.

Custom Configuration

The generated config/default.ts can be extended with your own environment variables and settings.

Database Connection

MongoDB connection happens automatically on server start. Update MONGO_URI in .env to point to your database.

📋 Requirements

  • Node.js v14 or higher (v16+ recommended)
  • npm v6 or higher (v8+ recommended)
  • MongoDB (optional, only if using MongoDB features)

🤝 Contributing

Issues and pull requests are welcome! Visit the GitHub repository to contribute.

Development

# Clone the repository
git clone https://github.com/abdulwarith001/ts-node-init.git

# Install dependencies
npm install

# Test locally
npm link
ts-node-init test-project

📄 License

MIT

👨‍💻 Author

Enigmare

🙏 Acknowledgments

Built with ❤️ for developers who value their time.


Stop configuring. Start building. 🚀

Save hours of setup time and jump straight into development with production-ready project structure.