{"id":12299,"library":"unist-util-remove-position","title":"Unist Utility to Remove Position Information","description":"unist-util-remove-position is a specialized utility within the unified ecosystem, designed to strip the 'position' field from nodes within a unist Abstract Syntax Tree (AST). This is particularly useful when comparing trees, merging them, or when positional information is no longer relevant, such as after processing or when the AST is being used for structural analysis where source location is a distraction. The package is currently at stable version 5.0.0 and is actively maintained by the unified collective, aligning with their standard release cadence that typically drops support for unmaintained Node.js versions with new major releases. It differentiates itself by offering a focused solution for position removal, contrasting with related utilities that extract or stringify position data.","status":"active","version":"5.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/syntax-tree/unist-util-remove-position","tags":["javascript","unist","unist-util","util","utility","remove","position","location","clean","typescript"],"install":[{"cmd":"npm install unist-util-remove-position","lang":"bash","label":"npm"},{"cmd":"yarn add unist-util-remove-position","lang":"bash","label":"yarn"},{"cmd":"pnpm add unist-util-remove-position","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is ESM-only since v4.0.0. CommonJS `require()` is not supported.","wrong":"const removePosition = require('unist-util-remove-position')","symbol":"removePosition","correct":"import { removePosition } from 'unist-util-remove-position'"},{"note":"This is a TypeScript type import for configuring the `removePosition` function. It's not a runtime value.","symbol":"Options","correct":"import type { Options } from 'unist-util-remove-position'"}],"quickstart":{"code":"import {fromMarkdown} from 'mdast-util-from-markdown'\nimport {removePosition} from 'unist-util-remove-position'\n\n// Create a sample Markdown AST with positional information\nconst markdown = 'Some _emphasis_, **importance**, and `code`.'\nconst tree = fromMarkdown(markdown)\n\nconsole.log('Tree with positions:')\nconsole.dir(tree, {depth: null})\n\n// Remove positional information from the tree, forcing deletion of fields\nremovePosition(tree, {force: true})\n\nconsole.log('\\nTree without positions:')\nconsole.dir(tree, {depth: null})","lang":"typescript","description":"Demonstrates how to parse Markdown into a unist AST using `mdast-util-from-markdown` and then remove all `position` fields from its nodes using `unist-util-remove-position`."},"warnings":[{"fix":"Upgrade your Node.js environment to version 16 or newer, or stick to `unist-util-remove-position@^4` for older Node.js versions.","message":"Version 5.0.0 changes to require Node.js 16 or higher. Older Node.js versions are no longer supported.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Change calls from `removePosition(node, true)` to `removePosition(node, { force: true })`.","message":"Version 5.0.0 removed the `force` shortcut. Previously, `removePosition(tree, true)` would work. Now, the `force` option must be passed as an object: `{ force: true }`.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Adjust any code that expects a return value from `removePosition`. The function now mutates the tree in-place and explicitly yields `undefined`.","message":"Version 5.0.0 changed the return value of `removePosition` to `undefined`. Previously, it might have returned the `node` itself.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Migrate your project to use ES modules (`import`/`export`) or use a tool like Rollup/Webpack to bundle for CJS environments. For Node.js, ensure your `package.json` specifies `\"type\": \"module\"` or use `.mjs` files.","message":"Version 4.0.0 switched to being an ESM-only package. It no longer supports CommonJS `require()` syntax.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure `@types/unist` is updated to a compatible version and check your `tsconfig.json` for strictness settings that might expose new type issues.","message":"Version 3.0.0 introduced TypeScript types. While generally beneficial, it could cause compilation errors if your TypeScript configuration or dependent types are incompatible.","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Update your import statement to `import { removePosition } from 'unist-util-remove-position'` and ensure your Node.js project or file is configured for ES Modules (e.g., `\"type\": \"module\"` in `package.json`).","cause":"Attempting to import an ESM-only package using CommonJS `require()` in a non-ESM context.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/unist-util-remove-position/index.js not supported."},{"fix":"Use `import { removePosition } from 'unist-util-remove-position'` for ESM. Double-check your environment is correctly configured for ESM if you're getting `ERR_REQUIRE_ESM`.","cause":"Incorrect import syntax for an ESM module, or attempting to access a named export as a default export, or a CommonJS `require()` failure.","error":"TypeError: removePosition is not a function"},{"fix":"Update the call to `removePosition(node, { force: true })` to use the new options object syntax.","cause":"Using the old `force: true` shortcut with `removePosition(node, true)` after upgrading to v5.0.0.","error":"TypeError: Argument of type 'boolean' is not assignable to parameter of type 'Options | undefined'."},{"fix":"Upgrade your Node.js environment to version 16 or newer. Alternatively, if forced to use an older Node.js, downgrade to `unist-util-remove-position@^4`.","cause":"Running the package with an unsupported Node.js version (specifically, older than 16.0).","error":"Node.js version X is not supported by 'unist-util-remove-position@5.0.0'."}],"ecosystem":"npm"}