{"id":18653,"library":"parser-front-matter","title":"parser-front-matter","description":"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.","status":"maintenance","version":"1.6.4","language":"javascript","source_language":"en","source_url":"https://github.com/jonschlinkert/parser-front-matter","tags":["javascript","consolidate","data","front","front-matter","gray-matter","matter","meta","metadata"],"install":[{"cmd":"npm install parser-front-matter","lang":"bash","label":"npm"},{"cmd":"yarn add parser-front-matter","lang":"bash","label":"yarn"},{"cmd":"pnpm add parser-front-matter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"core parsing logic","package":"gray-matter","optional":false}],"imports":[{"note":"ESM only since v? package.json lacks type:module, but exports exist; use dynamic import for CJS.","wrong":"const parser = require('parser-front-matter')","symbol":"default","correct":"import parser from 'parser-front-matter'"},{"note":"Named export available in both ESM and CJS via package.json exports.","wrong":"const { parse } = require('parser-front-matter')","symbol":"parse","correct":"import { parse } from 'parser-front-matter'"},{"note":"Synchronous variant, same import path.","wrong":null,"symbol":"parseSync","correct":"import { parseSync } from 'parser-front-matter'"}],"quickstart":{"code":"import parser from 'parser-front-matter';\n\n// Parse a string with front matter\nparser.parse('---\\ntitle: Hello\\n---\\nWorld', (err, file) => {\n  if (err) console.error(err);\n  console.log(file.data.title); // 'Hello'\n  console.log(file.content);     // 'World'\n});\n\n// Parse an object (e.g., from gulp)\nconst fileObj = { contents: Buffer.from('---\\nfoo: bar\\n---\\nbaz') };\nparser.parse(fileObj, (err, file) => {\n  if (err) console.error(err);\n  console.log(file.data.foo); // 'bar'\n  console.log(file.content);  // 'baz'\n});\n\n// Synchronous usage\nconst result = parser.parseSync('---\\ntitle: Sync\\n---\\nContent');\nconsole.log(result.data.title); // 'Sync'","lang":"typescript","description":"Shows async and sync front matter parsing from string and object, with error handling."},"warnings":[{"fix":"Consider using gray-matter directly or a maintained alternative.","message":"Package is not actively maintained; last release 2019. May not work with modern Node.js versions (>=14).","severity":"gotcha","affected_versions":">=1.6.4"},{"fix":"Use dynamic import() or CommonJS require() for compatibility.","message":"ESM usage may fail in Node.js <12 or with certain bundlers due to lack of 'type: module' in package.json.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Wrap in a promise: new Promise((resolve, reject) => parser.parse(str, (err, file) => err ? reject(err) : resolve(file))).","message":"The parse callback is error-first but does not return a promise. No promise or async/await support.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install parser-front-matter --save","cause":"Package is not installed or spelling mistake.","error":"Cannot find module 'parser-front-matter'"},{"fix":"Use import parser from 'parser-front-matter' then parser.parse() or import { parse } from 'parser-front-matter'.","cause":"Importing default as an object without destructuring or using wrong import syntax.","error":"TypeError: parser.parse is not a function"},{"fix":"Run npm install gray-matter","cause":"Missing dependency 'gray-matter' (should be installed automatically but may be missing in some environments).","error":"gray-matter is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}