{"id":18979,"library":"babel-check-duplicated-nodes","title":"babel-check-duplicated-nodes","description":"Babel helper utility (v1.0.0) that checks an AST for duplicated nodes, throwing a descriptive error if any are found. Originally extracted from Babel's test fixture runner, this tool helps Babel transform authors catch subtle bugs caused by node reuse. It is a niche package with a single API call, no active release cadence, and is intended for internal use during transform development rather than general production.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/Andarist/babel-check-duplicated-nodes","tags":["javascript","babel"],"install":[{"cmd":"npm install babel-check-duplicated-nodes","lang":"bash","label":"npm"},{"cmd":"yarn add babel-check-duplicated-nodes","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-check-duplicated-nodes","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package exports a named function, not a default export.","wrong":"import checkDuplicatedNodes from 'babel-check-duplicated-nodes'","symbol":"checkDuplicatedNodes","correct":"import { checkDuplicatedNodes } from 'babel-check-duplicated-nodes'"}],"quickstart":{"code":"import { checkDuplicatedNodes } from 'babel-check-duplicated-nodes';\nimport * as babel from '@babel/core';\n\nconst code = 'const x = 1; const y = 2;';\nconst ast = babel.parseSync(code, { filename: 'test.js' });\n\n// Simulate a duplicated node: reuse the same node twice\nconst duplicateNode = ast.program.body[0];\nast.program.body.push(duplicateNode);\n\ntry {\n  checkDuplicatedNodes(babel, ast);\n} catch (e) {\n  console.error(e.message);\n}","lang":"javascript","description":"Demonstrates how to use checkDuplicatedNodes with @babel/core to detect duplicated AST nodes."},"warnings":[{"fix":"Use 'const { checkDuplicatedNodes } = require('babel-check-duplicated-nodes')'.","message":"The pattern 'require('babel-check-duplicated-nodes').default' is incorrect; the package does not have a default export.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure you only call this function on ASTs generated by Babel's parser, not third-party parsers.","message":"This package is intended for internal use by Babel transform authors, not for general AST manipulation. Incorrect usage may produce false negatives.","severity":"gotcha","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":"Use `import { checkDuplicatedNodes } from 'babel-check-duplicated-nodes'` or `const { checkDuplicatedNodes } = require('babel-check-duplicated-nodes')`.","cause":"Default import usage instead of named import.","error":"TypeError: checkDuplicatedNodes is not a function"},{"fix":"Run `npm install babel-check-duplicated-nodes --save-dev`.","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'babel-check-duplicated-nodes'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}