Registry / serialization / parser-front-matter

parser-front-matter

JSON →
library1.6.4jsnpmunverified

Front matter parsing middleware based on gray-matter, providing a callback-oriented API for parsing YAML-like front matter from strings or file objects. Version 1.6.4 is the latest stable release, with no major updates since 2019. It supports both async (parse) and sync (parseSync) methods, and is designed for use with build tools like assemble, verb, or generate. Unlike direct gray-matter usage, this package integrates via middleware conventions, but it is slow, unmaintained, and lacks TypeScript definitions.

npm install parser-front-matter
INSTALL
IMPORT
SIG · PARSER-FRONT-MATTE
P
parser-front-matter
serializationjavascriptv1.6.4
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.

default
import parser from 'parser-front-matter'
const parser = require('parser-front-matter')
ESM only since v? package.json lacks type:module, but exports exist; use dynamic import for CJS.
parse
import { parse } from 'parser-front-matter'
const { parse } = require('parser-front-matter')
Named export available in both ESM and CJS via package.json exports.
parseSync
import { parseSync } from 'parser-front-matter'
Synchronous variant, same import path.

Shows async and sync front matter parsing from string and object, with error handling.

import parser from 'parser-front-matter'; // Parse a string with front matter parser.parse('---\ntitle: Hello\n---\nWorld', (err, file) => { if (err) console.error(err); console.log(file.data.title); // 'Hello' console.log(file.content); // 'World' }); // Parse an object (e.g., from gulp) const fileObj = { contents: Buffer.from('---\nfoo: bar\n---\nbaz') }; parser.parse(fileObj, (err, file) => { if (err) console.error(err); console.log(file.data.foo); // 'bar' console.log(file.content); // 'baz' }); // Synchronous usage const result = parser.parseSync('---\ntitle: Sync\n---\nContent'); console.log(result.data.title); // 'Sync'
Debug
Known issues
gotchaPackage is not actively maintained; last release 2019. May not work with modern Node.js versions (>=14).
fix
Consider using gray-matter directly or a maintained alternative.
affects: >=1.6.4
breakingESM usage may fail in Node.js <12 or with certain bundlers due to lack of 'type: module' in package.json.
fix
Use dynamic import() or CommonJS require() for compatibility.
affects: >=1.0.0
deprecatedThe parse callback is error-first but does not return a promise. No promise or async/await support.
fix
Wrap in a promise: new Promise((resolve, reject) => parser.parse(str, (err, file) => err ? reject(err) : resolve(file))).
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'parser-front-matter'
Package is not installed or spelling mistake.
fix
Run npm install parser-front-matter --save
TypeError: parser.parse is not a function
Importing default as an object without destructuring or using wrong import syntax.
fix
Use import parser from 'parser-front-matter' then parser.parse() or import { parse } from 'parser-front-matter'.
gray-matter is not defined
Missing dependency 'gray-matter' (should be installed automatically but may be missing in some environments).
fix
Run npm install gray-matter
Upgrade
Version history
1.6.4latest on npm
Audit
Dependencies
gray-matterrequiredcore parsing logic
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources
parser-front-matter — npm install parser-front-matter · libregistry