Registry / serialization / changelog-parser

changelog-parser

JSON →
library0.0.8jsnpmunverified

The `changelog-parser` package provides a utility to parse and structure content from CHANGELOG.md files within Node.js environments. It extracts key information such as the changelog's title, a general description, and a list of versions, each containing its version number, title, date, raw body, and a parsed body. The current stable version is 3.0.1. The package maintains an irregular release cadence, driven by bug fixes, dependency updates, and new features. It offers flexible input options, allowing parsing from either a file path or a raw text string. A key differentiator is its ability to automatically remove Markdown formatting from entries by default, configurable via an option. It also supports both callback-based and Promise-based APIs, catering to different asynchronous programming styles. The module is primarily focused on adhering to common Markdown changelog formats, supporting various date formats and header levels (H1 or H2) for version sections.

npm install changelog-parser
INSTALL
IMPORT
SIG · CHANGELOG-PARSER
C
changelog-parser
serializationjavascriptv0.0.8
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.

parseChangelog
const parseChangelog = require('changelog-parser')
import { parseChangelog } from 'changelog-parser'
This package is a CommonJS module (`"type": "commonjs"`) and should be imported with `require()`.
parseChangelog
const parseChangelog = require('changelog-parser')
import parseChangelog from 'changelog-parser'
The module exports a single function as its default, but it's a CommonJS module. ESM default imports won't work without a transpiler or specific Node.js configuration.
parseChangelog
const parseChangelog = require('changelog-parser')
const { parseChangelog } = require('changelog-parser')
The package exports a single function as its module.exports, not an object with a named export.

This quickstart demonstrates parsing a changelog from both a temporary file and a direct text string, showcasing the promise-based API and the `removeMarkdown` option. It also includes cleanup for the temporary file.

const fs = require('fs'); const path = require('path'); const parseChangelog = require('changelog-parser'); const changelogContent = `# My Awesome Project\n\nA brief description of the project.\n\n## 1.0.1 - 2023-10-26\n### Fixed\n- Resolved issue with data serialization.\n\n## 1.0.0 - 2023-10-20\n### Added\n- Initial release with core features.\n\n### Changed\n- Updated dependency versions.`; const tempChangelogPath = path.join(__dirname, 'temp-CHANGELOG.md'); fs.writeFileSync(tempChangelogPath, changelogContent); async function runParser() { try { // Parse from file path const resultFromFile = await parseChangelog({ filePath: tempChangelogPath }); console.log('Parsed from file title:', resultFromFile.title); console.log('First version:', resultFromFile.versions[0].version); // Parse from text directly, keeping markdown const resultFromText = await parseChangelog({ text: changelogContent, removeMarkdown: false }); console.log('\nParsed from text description:', resultFromText.description); console.log('First version body (with markdown):', resultFromText.versions[0].body); } catch (err) { console.error('Error parsing changelog:', err); } finally { fs.unlinkSync(tempChangelogPath); // Clean up temp file } } runParser();
Debug
Known issues
breakingVersion 3.0.0 of `changelog-parser` dropped support for Node.js 12, which reached its End-of-Life. Users on Node.js 12 or older must upgrade their Node.js environment to version 14 or higher.
fix
Upgrade Node.js to version 14 or higher (`nvm install 14 && nvm use 14` or similar).
affects: >=3.0.0
gotchaThe `removeMarkdown` option defaults to `true`. This means markdown markup like `*`, `-`, `##`, etc., will be stripped from the changelog entry bodies by default. If you need to retain the original markdown, explicitly set `removeMarkdown: false` in the options object.
fix
To preserve markdown, pass `{ removeMarkdown: false }` in the options object: `parseChangelog({ filePath: 'CHANGELOG.md', removeMarkdown: false })`.
affects: >=2.7.0
gotchaWhen using the `parseChangelog` function, you must provide either the `filePath` option (path to the changelog file) or the `text` option (the raw changelog content as a string). Failing to provide either will result in an error.
fix
Ensure your options object includes either `filePath: '/path/to/CHANGELOG.md'` or `text: 'your changelog content string'`.
affects: >=2.8.0
Errors
Common errors & fixes
Error: You must provide either 'filePath' or 'text' option.
The `parseChangelog` function was called without specifying either a `filePath` or `text` option.
fix
Provide an options object with either a `filePath` string or a `text` string. Example: `parseChangelog({ filePath: 'path/to/CHANGELOG.md' })` or `parseChangelog({ text: '...' })`.
TypeError: parseChangelog is not a function
Attempting to import `changelog-parser` using ESM `import` syntax (`import { parseChangelog } from 'changelog-parser'`) in a pure ESM context, while the package is a CommonJS module.
fix
Use the CommonJS `require` syntax: `const parseChangelog = require('changelog-parser')`.
Error: ENOENT: no such file or directory, open 'non-existent-path/CHANGELOG.md'
The `filePath` option pointed to a file that does not exist or is inaccessible.
fix
Verify that the `filePath` provided is correct and that the Node.js process has read permissions for the file. Use an absolute path or ensure the relative path is correct from `process.cwd()`.
Upgrade
Version history
0.0.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
changelog-parser — npm install changelog-parser · libregistry