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

docx-mergex

v0.0.2

Published

Merge .docx files with formatting preserved (pure Node.js)

Readme


📦 docx-mergex

Merge multiple .docx files into one — with formatting preserved — using pure Node.js. No Python. No LibreOffice. Just ZIP-level OpenXML parsing and reassembly.


✅ Features

  • 🔒 Full formatting preserved: styles, bold, lists, paragraphs, tables
  • ⚡ No external deps: pure Node.js (no Python or LibreOffice)
  • 🖥️ Cross-platform: macOS, Linux, and Windows
  • 🛠️ CLI & API: use from the command line or in your code
  • 🔄 Safe merge: keeps metadata, stylesheets, and zip structure untouched
  • 🧪 CI/CD-ready: perfect for templating pipelines and bulk automation

🚀 CLI Usage

npx docx-mergex <input-folder> [output.docx]
  • <input-folder>: directory containing your .docx files
  • [output.docx]: (optional) output filename (defaults to merged.docx)

Example:

npx docx-mergex ./my-docx-folder merged.docx

Files are merged in alphabetical order by filename.


📚 Programmatic API

const mergeDocx = require("docx-mergex");

mergeDocx("./docs", "combined.docx")
  .then(() => console.log("✅ Merge complete"))
  .catch(err => console.error("❌ Merge failed:", err));
  • ./docs: folder containing .docx files
  • "combined.docx": desired output path

⚠️ Limitations

  • Only word/document.xml contents are merged — headers, footers, and numbering beyond the body are not preserved
  • No page/section breaks are inserted by default (coming soon)
  • Input files must be valid .docx (e.g. Word exports, Google Docs exports)
  • Non-.docx files and hidden folders are skipped silently

❌ Common Errors

| Error | Cause | Solution | | ---------------------------------------- | ----------------------------------------------- | ------------------------------------------ | | EISDIR: illegal operation on directory | Output path is a directory, not a file | Provide a valid .docx filename | | The XML document isn’t in Word format | Merged XML is malformed or ZIP structure broken | Ensure input docs are valid; update module | | No .docx files found | Input folder contains no .docx files | Check folder path and file extension |


🧪 Testing Locally

  1. Link the module (from its folder):

    npm link
  2. In your test folder, link it in:

    npm link docx-mergex
  3. Prepare sample docs:

    mkdir test-docs
    cp ~/Downloads/*.docx test-docs/
  4. Run the CLI:

    docx-mergex ./test-docs merged.docx
  5. Verify in Microsoft Word or LibreOffice.

  6. To unlink after testing:

    # In test folder
    npm unlink docx-mergex
    
    # In module folder
    npm unlink

🤖 Roadmap / Coming Soon

  • Insert section/page breaks between merged documents
  • Merge headers, footers, and numbering
  • Recursive merging from nested folders
  • Option to insert filename as heading before each document
  • CLI flag for custom merge order

👥 Contributing

We welcome contributions!

  1. Fork this repo

  2. Run npm install

  3. Make your changes (add features, fix bugs)

  4. Test via:

    node bin/cli.js <input> <output>
  5. Submit a Pull Request with a clear description of your changes


📄 License

MIT © 2025 Huzaifa Azim