{"id":14228,"library":"vfile-message","title":"VFile Message Utility","description":"vfile-message is a JavaScript utility for creating standardized lint messages within the `vfile` ecosystem. It provides a `VFileMessage` class, extending `Error`, that can be used to represent warnings or errors, particularly when a full `VFile` instance is not available or desired. Currently at version 4.0.3, the package maintains an active release cadence with frequent updates focusing on type improvements and minor fixes. Its core differentiator is the ability to generate structured messages with fields like `reason`, `line`, `column`, `ruleId`, and `source`, making them consumable by linters and other processing tools that operate on virtual files. It integrates well with the Unified (unist) ecosystem, offering TypeScript definitions for robust development.","status":"active","version":"4.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/vfile/vfile-message","tags":["javascript","file","message","utility","util","vfile-util","vfile","virtual","typescript"],"install":[{"cmd":"npm install vfile-message","lang":"bash","label":"npm"},{"cmd":"yarn add vfile-message","lang":"bash","label":"yarn"},{"cmd":"pnpm add vfile-message","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"vfile-message is ESM-only since v4.0.0. CommonJS `require()` is not supported.","wrong":"const VFileMessage = require('vfile-message')","symbol":"VFileMessage","correct":"import { VFileMessage } from 'vfile-message'"},{"note":"This is a TypeScript type for configuring VFileMessage instances.","symbol":"Options","correct":"import type { Options } from 'vfile-message'"}],"quickstart":{"code":"import { VFileMessage } from 'vfile-message';\n\nconst message = new VFileMessage(\n  'Unexpected unknown word `braavo`, did you mean `bravo`?',\n  {place: {column: 8, line: 1}, ruleId: 'typo', source: 'spell'}\n);\n\nconsole.log(message);\n/*\nYields:\n[1:8: Unexpected unknown word `braavo`, did you mean `bravo`?] {\n  reason: 'Unexpected unknown word `braavo`, did you mean `bravo`?',\n  line: 1,\n  column: 8,\n  ancestors: undefined,\n  cause: undefined,\n  fatal: undefined,\n  place: {line: 1, column: 8},\n  ruleId: 'typo',\n  source: 'spell'\n}\n*/","lang":"typescript","description":"Demonstrates creating a new `VFileMessage` instance with a reason and detailed positional information, then logging it to the console."},"warnings":[{"fix":"Upgrade your Node.js environment to version 16 or later. If unable to upgrade, pin vfile-message to a version below 4.0.0 (e.g., `npm install vfile-message@^3`).","message":"vfile-message v4.0.0 and later require Node.js 16 or higher due to the transition to ESM and export maps.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Migrate code accessing `message.position` to `message.place`. For example, `message.position.line` should become `message.place.line`.","message":"The `position` field on `VFileMessage` instances was removed in v4.0.0. It has been replaced by the `place` field, which accepts `Point` or `Position` objects from unist.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure your project is configured for ESM (e.g., `\"type\": \"module\"` in `package.json` or using `.mjs` extensions) and switch all imports to use `import { VFileMessage } from 'vfile-message'`.","message":"vfile-message v4.0.0 is ESM-only and utilizes export maps. This means CommonJS `require()` syntax will no longer work, and consumers must use `import` statements.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Update any comparisons or checks that specifically relied on `null` (e.g., `property === null`) to check for `undefined` or general falsiness if applicable (e.g., `property == null` to catch both `null` and `undefined`).","message":"Properties on `VFileMessage` that could previously be `null` are now `undefined` in v4.0.0, aligning with modern JavaScript practices.","severity":"breaking","affected_versions":">=4.0.0"}],"env_vars":null,"search_vec":"'4.0.3':50 'abil':73 'activ':55 'avail':44 'cadenc':57 'class':24 'column':83 'consum':89 'core':69 'creat':12 'current':47 'definit':111 'desir':46 'develop':114 'differenti':70 'ecosystem':19,108 'error':26,35 'extend':25 'field':79 'file':100,116 'fix':67 'focus':61 'frequent':59 'full':39 'generat':75 'improv':64 'instanc':41 'integr':102 'javascript':9,115 'like':80 'line':82 'lint':14 'linter':91 'maintain':53 'make':87 'messag':2,6,15,77,117 'minor':66 'offer':109 'oper':97 'packag':52 'particular':36 'process':94 'provid':21 'reason':81 'releas':56 'repres':32 'robust':113 'ruleid':84 'sourc':86 'standard':13 'structur':76 'tool':95 'type':63 'typescript':110,125 'unifi':106 'unist':107 'updat':60 'use':30 'util':3,10,118,119,122 'version':49 'vfile':1,5,18,40,121,123 'vfile-messag':4 'vfile-util':120 'vfilemessag':23 'virtual':99,124 'warn':33 'well':103 'within':16","created_at":"2026-04-20T01:58:36.269925+00:00","updated_at":"2026-04-20T01:58:36.269925+00:00","problems":[{"fix":"Switch to ESM `import` syntax: `import { VFileMessage } from 'vfile-message'`. Ensure your project's `package.json` specifies `\"type\": \"module\"` or your file uses the `.mjs` extension.","cause":"Attempting to import `vfile-message` using CommonJS `require()` in an ESM context, which is not supported since v4.0.0.","error":"ReferenceError: require is not defined"},{"fix":"The `position` property was replaced by `place`. Update your code to use `message.place.line`, `message.place.column`, etc., instead of `message.position`.","cause":"Accessing the deprecated `position` property on a `VFileMessage` instance after upgrading to v4.0.0.","error":"TypeError: Cannot read properties of undefined (reading 'start') OR Property 'position' does not exist on type 'VFileMessage'"},{"fix":"Upgrade your Node.js environment to version 16 or newer. Alternatively, if upgrading Node.js is not feasible, downgrade `vfile-message` to a v3 release (e.g., `npm install vfile-message@^3`).","cause":"This error can occur when using `vfile-message` v4.0.0 or higher in a Node.js environment older than v16, which lacks full support for ESM and export maps.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'vfile-message' from '/path/to/your/file.js'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/vfile/vfile-message","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vfile-message","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}