unist-util-visit-children is a focused utility within the unified ecosystem designed to create a reusable function for iterating over only the direct children of a given unist (Universal Syntax Tree) node. The current stable version is 3.0.0. Releases are tied to major Node.js version support, with new major versions often dropping support for unmaintained Node.js versions. While it provides a specific function for direct child visitation, the package's own documentation recommends using `unist-util-visit` for most general tree traversal needs due to its broader capabilities. It's distinct in its narrow scope, avoiding recursive traversal and providing a lightweight, dedicated mechanism for immediate child processing.
npm install unist-util-visit-childrenVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use `visitChildren` to iterate over the direct children of a unist tree node, logging each child's type.
Ensure your project is running Node.js 16+ and update your `@types/unist` dependency if you are using TypeScript. Update your import paths if using bundlers that do not automatically resolve `export` maps.
Migrate your codebase to use ES Modules (ESM) syntax (`import ... from '...'`) and ensure your Node.js environment or bundler is configured for ESM.
For most tree traversal scenarios, consider using `unist-util-visit` (or `unist-util-visit-parents` for parent access) for a more robust and widely applicable solution, unless your use case strictly requires only visiting direct children without recursion.
Change `const { visitChildren } = require('unist-util-visit-children')` to `import { visitChildren } from 'unist-util-visit-children'` and ensure your environment supports ESM.Upgrade Node.js to version 16 or newer. If using a bundler, ensure it's configured to process ES Modules from `node_modules`.
Ensure you are using named imports: `import { visitChildren } from 'unist-util-visit-children'`. Do not try to destructure a default export, as there is none.No dependency data recorded yet.