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

remove-comments-cli

v1.0.0

Published

A fast and flexible CLI tool to remove comments from JavaScript/TypeScript files while preserving important ones

Readme

remove-comments-cli

npm version CI codecov License: MIT PRs Welcome

A fast and flexible CLI tool to remove comments from JavaScript/TypeScript files while preserving important ones.

Features

  • 🚀 Fast and memory-efficient comment removal
  • 💡 Preserve important comments using markers
  • 🌟 Support for JavaScript, TypeScript, and JSX
  • 🔍 Smart handling of strings, regex, and JSX syntax
  • 📁 Process multiple files using glob patterns
  • 🎯 Configurable output directory

Installation

npm install remove-comments-cli --save-dev

Usage

Basic Usage

Remove all comments from a file:

npx remove-comments input.ts > output.ts

Process multiple files using glob patterns:

npx remove-comments "src/**/*.{js,ts,jsx,tsx}" --outDir dist

Preserving Comments

By default, comments starting with ! are preserved:

// This comment will be removed
//! This important comment will be preserved
/* This block comment will be removed */
/*! This important block comment will be preserved */

You can specify custom markers:

# Preserve comments starting with # or *
npx remove-comments input.ts -k "#*" > output.ts

CLI Options

npx remove-comments --help

Options:
  -k, --keep-markers <chars>  Characters that mark comments to preserve (default: "!")
  -o, --outDir <dir>         Output directory for processed files
  -v, --verbose             Print detailed processing information
  -h, --help                Display help information

Examples

Process TypeScript files and preserve comments starting with ! or #:

npx remove-comments "src/**/*.ts" -k "!#" --outDir dist

Process JSX/TSX files and preserve comments starting with *:

npx remove-comments "src/**/*.{jsx,tsx}" -k "*" --outDir dist

Process a single file and output to stdout:

npx remove-comments input.js > output.js

Performance

The tool is optimized for performance and memory efficiency:

  • ⚡ Processes ~1000 files/second on modern hardware
  • 📉 Low memory footprint (~10MB for 1000 files)
  • 🔄 Streaming file processing for large files
  • 💻 Multi-threaded processing for large directories

Compatibility

| Node.js Version | Support Status | |----------------|----------------| | 20.x | ✅ Full | | 18.x (LTS) | ✅ Full | | 16.x | ❌ Not supported|

Tested on:

  • Windows 10/11
  • macOS 10.15+
  • Ubuntu 20.04+

Troubleshooting

Common Issues

  1. "Error: ENOENT: no such file or directory"

    • Check if the file paths are correct
    • Ensure glob patterns are quoted in the shell
    • Use forward slashes (/) even on Windows
  2. "SyntaxError: Unexpected token"

    • Verify the input file is valid JavaScript/TypeScript
    • Check for malformed comments or JSX syntax
    • Try running with --verbose for more details
  3. "Error: Cannot find module"

    • Run npm install remove-comments-cli again
    • Check Node.js version compatibility
    • Verify package.json dependencies

Debug Mode

Run with debug logging enabled:

DEBUG=remove-comments* npx remove-comments input.ts

Security

  • No eval or dynamic code execution
  • No external network calls
  • Input validation for all file paths
  • Safe handling of symbolic links

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

MIT