Registry / http-networking / ast-walker-scope

ast-walker-scope

JSON →
library0.9.0jsnpmunverified

Traverse Babel AST with scope information. v0.9.0 is the current stable version, released with breaking changes dropping the types field and fixing a prototype pollution vulnerability. The package is ESM-only from v0.8.0, requires Node >=20.19.0, and builds on top of estree-walker. Key differentiators: scope tracking per node, support for Babel AST, and a simple hook context with scope, scopes, and level properties. Compared to estree-walker, it adds scope-aware traversal without a separate scope analysis step.

npm install ast-walker-scope
INSTALL
IMPORT
SIG · AST-WALKER-SCOPE
A
ast-walker-scope
http-networkingjavascriptv0.9.0
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.

walk
import { walk } from 'ast-walker-scope'
const walk = require('ast-walker-scope')
ESM-only since v0.8.0; no CommonJS export. Use dynamic import() if needed.
Scope
import type { Scope } from 'ast-walker-scope'
import { Scope } from 'ast-walker-scope'
Scope is a TypeScript type, not a value. Use `import type` for type-only imports.
HookContext
import type { HookContext } from 'ast-walker-scope'
import { HookContext } from 'ast-walker-scope'
HookContext is a TypeScript type, not a runtime value. Must be imported as type.

Demonstrates basic usage of walk() with scope tracking in enter/leave hooks.

import { walk } from 'ast-walker-scope'; const code = ` const a = 1; { const b = 2; console.log(a, b); } `.trim(); walk(code, { enter(node) { console.log(`Enter: ${node.type}`); }, leave(node) { if (node.type === 'CallExpression') { console.log('Scope variables:', Object.keys(this.scope)); } }, });
Debug
Known issues
breakingRemoved types field from package.json; TypeScript types may not be resolvable without separate types export.
fix
Use `import type` and ensure your tsconfig includes `node_modules/ast-walker-scope` types correctly; or install `@types/ast-walker-scope` if available.
affects: >=0.9.0
breakingDropped CommonJS build and Node.js 18 support.
fix
Migrate to ESM syntax (`import` instead of `require`). Upgrade Node.js to >=20.19.0.
affects: >=0.8.0
breakingDropped Node.js 16 support.
fix
Upgrade Node.js to >=18 or later (but note >=0.8.0 requires >=20.19.0).
affects: >=0.7.0
breakingDefault to ESM from v0.6.0; CJS require() no longer works without dynamic import.
fix
Switch to `import` syntax or use dynamic `import('ast-walker-scope')`.
affects: >=0.6.0
deprecatedPrototype pollution via __proto__ identifier was fixed in v0.9.0.
fix
Upgrade to v0.9.0 or later to avoid potential prototype pollution.
affects: <0.9.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/ast-walker-scope/dist/index.js from /path/to/project/index.js not supported.
Package is ESM-only from v0.8.0 (v0.6.0 if using default ESM).
fix
Replace `require('ast-walker-scope')` with `import { walk } from 'ast-walker-scope'` or use dynamic `import()`.
TypeError: walk is not a function
Incorrect import pattern (e.g., default import instead of named import).
fix
Use `import { walk } from 'ast-walker-scope'` (named import).
Module not found: Can't resolve 'ast-walker-scope' in '/path/to/project'
Package not installed or misspelled.
fix
Run `npm install ast-walker-scope` and ensure the import path is correct.
Upgrade
Version history
0.9.0latest on npm
Audit
Dependencies
@babel/typesrequiredUsed for Babel AST node type definitions and utilities.
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
ast-walker-scope — npm install ast-walker-scope · libregistry