Registry / serialization / docx-parser

docx-parser

JSON →
library1.0.3jsnpmunverified

The `docx-parser` package, at version 0.2.1, is an abandoned JavaScript library last published in October 2016. Its primary function is to extract plain text content from Microsoft Word `.docx` files using a simple, callback-based CommonJS API. It focuses solely on basic text extraction without support for rich text formatting, images, tables, or intricate document structures. Due to its age, it lacks modern features like Promise-based APIs, ESM support, or TypeScript typings, and is not actively maintained. Developers seeking robust DOCX parsing with comprehensive features, active development, and modern JavaScript/TypeScript compatibility should consider contemporary alternatives such as `@thasmorato/docx-parser` or `officeparser`, which offer streaming capabilities, memory efficiency, detailed Abstract Syntax Tree (AST) output, and broader support for office file formats.

npm install docx-parser
INSTALL
IMPORT
SIG · DOCX-PARSER
D
docx-parser
serializationjavascriptv1.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

docxParser
const docxParser = require('docx-parser');
import docxParser from 'docx-parser';
This package is CommonJS-only and does not support ES Modules. Attempting to use `import` will result in a module resolution error.
parseDocx
const docxParser = require('docx-parser'); docxParser.parseDocx('path/to/file.docx', (data) => { /* ... */ });
import { parseDocx } from 'docx-parser';
The `parseDocx` function is exposed as a method on the default CommonJS export. There are no named exports.

Demonstrates how to import the `docx-parser` module and use its `parseDocx` function to extract plain text from a DOCX file using a callback. Users must provide a valid DOCX file.

const docxParser = require('docx-parser'); const path = require('path'); const fs = require('fs'); // Create a dummy docx file for demonstration, as a real one is needed for parsing. // In a real application, you would replace 'example.docx' with your actual file. // Note: This package expects a valid .docx file, which is a zipped XML structure. // Creating one programmatically for a quickstart is complex, so this is illustrative. // For a runnable example, ensure 'example.docx' exists in your project root. const dummyDocxPath = path.join(__dirname, 'example.docx'); // A real .docx is a zip file containing XML. A simple text file renamed to .docx will fail. // For testing, place a real, simple .docx file at dummyDocxPath. if (!fs.existsSync(dummyDocxPath)) { console.warn(`Warning: '${dummyDocxPath}' not found. Please create a valid .docx file for parsing.`); console.warn('Skipping parsing example.'); } else { docxParser.parseDocx(dummyDocxPath, function(data){ console.log('Extracted Text:', data); }); }
Debug
Known issues
breakingThis package is CommonJS-only and does not support ES Modules (`import`/`export`). Attempting to use ES module syntax will lead to module resolution errors.
fix
Ensure your project uses CommonJS (`require()`) for this package, or use a tool like Webpack/Rollup with CJS compatibility configured. Consider migrating to a modern parser for ESM support.
affects: >=0.1.0
deprecatedThe package uses a callback-based API, which is a legacy pattern in modern JavaScript development. It does not offer a Promise-based or async/await interface.
fix
Wrap the callback function in a Promise manually if you need `async/await` compatibility, or use an actively maintained package that supports modern asynchronous patterns.
affects: >=0.1.0
gotchaThe package is no longer maintained, with the last publish over 10 years ago. This means it may have compatibility issues with newer Node.js versions, unpatched bugs, and lacks new features or security updates.
fix
For new projects or production environments, it is highly recommended to use a currently maintained and more robust DOCX parsing library. Examples include `@thasmorato/docx-parser` or `officeparser`.
affects: >=0.1.0
gotchaThe package extracts only plain text. It does not support parsing rich text formatting, images, tables, headers/footers, or other complex document structures found in DOCX files.
fix
If your application requires extraction of formatting, images, or a structured representation of the DOCX content (e.g., as an AST), this package is unsuitable. Look for libraries that explicitly advertise 'rich text parsing', 'AST output', or 'HTML conversion'.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'docx-parser'
Attempting to import `docx-parser` using ES Modules syntax (`import`) in a context that does not allow CJS interop, or simply the package is not installed.
fix
Use `const docxParser = require('docx-parser');` instead of `import` statements. Also ensure the package is installed via `npm install docx-parser`.
TypeError: docxParser.parseDocx is not a function
This error typically occurs if the `docx-parser` module was imported incorrectly, or if the `require()` call failed silently, resulting in `docxParser` being `undefined` or an empty object.
fix
Verify that `const docxParser = require('docx-parser');` is at the top of your file and that `npm install docx-parser` completed successfully. Ensure the variable name matches `docxParser`.
Error: File is not a zip
DOCX files are essentially ZIP archives containing XML. This error indicates that the provided file is either corrupted, not a valid .docx file, or potentially a .doc file that was simply renamed to .docx.
fix
Ensure the input file is a genuine and uncorrupted `.docx` document. Open it in a program like 7-Zip or WinRAR to verify its internal structure (it should contain XML files like `word/document.xml`).
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources