{"id":10756,"library":"dom-node-types","title":"DOM Node Types","description":"This package `dom-node-types` (version 1.0.1) provides a lightweight solution for accessing the numeric constants associated with standard DOM Node types, such as `ELEMENT_NODE`, `TEXT_NODE`, and `COMMENT_NODE`. Its primary purpose is to offer these well-defined constants directly, enabling developers to avoid the necessity of including a full-fledged DOM implementation as a dependency when only these specific values are required for logic, type checking, or comparison. The package is maintained with a stable, low-cadence release cycle, reflecting its simple and immutable utility. Its key differentiator lies in its focused minimalism, providing essential DOM constants without introducing any additional overhead, browser API polyfills, or complex parsing capabilities, making it ideal for environments where a full DOM is unavailable or unnecessary.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/scienceai/dom-node-types","tags":["javascript","Document","Node","type"],"install":[{"cmd":"npm install dom-node-types","lang":"bash","label":"npm"},{"cmd":"yarn add dom-node-types","lang":"bash","label":"yarn"},{"cmd":"pnpm add dom-node-types","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"For accessing individual DOM Node type constants using named ESM imports.","wrong":"import ELEMENT_NODE from 'dom-node-types';","symbol":"ELEMENT_NODE","correct":"import { ELEMENT_NODE } from 'dom-node-types';"},{"note":"Imports all available DOM Node type constants into a single `nodeTypes` object in ESM environments.","wrong":"import nodeTypes from 'dom-node-types';","symbol":"nodeTypes (wildcard)","correct":"import * as nodeTypes from 'dom-node-types';"},{"note":"Retrieves an object containing all DOM Node type constants for CommonJS environments. Avoid `import` syntax in pure CJS files.","wrong":"import { ELEMENT_NODE } from 'dom-node-types';","symbol":"CommonJS (all)","correct":"const nodeTypes = require('dom-node-types');"},{"note":"Destructures a specific DOM Node type constant directly from the CommonJS export object.","wrong":"var ELEMENT_NODE = require('dom-node-types'); // only assigns the module object, not the constant directly","symbol":"CommonJS (individual)","correct":"const { ELEMENT_NODE } = require('dom-node-types');"}],"quickstart":{"code":"import { ELEMENT_NODE, TEXT_NODE, COMMENT_NODE } from 'dom-node-types';\n\nconsole.log('DOM Node Types Constants:');\nconsole.log(`ELEMENT_NODE: ${ELEMENT_NODE}`); // Expected: 1\nconsole.log(`TEXT_NODE: ${TEXT_NODE}`);       // Expected: 3\nconsole.log(`COMMENT_NODE: ${COMMENT_NODE}`); // Expected: 8\n\n// You can also import all as an object\nimport * as nodeTypes from 'dom-node-types';\nconsole.log(`\\nAll types object:`);\nconsole.log(`nodeTypes.DOCUMENT_NODE: ${nodeTypes.DOCUMENT_NODE}`); // Expected: 9\nconsole.log(`nodeTypes.CDATA_SECTION_NODE: ${nodeTypes.CDATA_SECTION_NODE}`); // Expected: 4\n\n// This package is purely for constants, it does not interact with actual DOM elements.","lang":"javascript","description":"Demonstrates how to import and access specific DOM Node type constants, as well as how to import all constants as a single object."},"warnings":[{"fix":"Understand its scope as solely a constant provider. Do not expect it to offer methods for creating or manipulating DOM nodes.","message":"This package only exports numeric constants representing DOM Node types. It does not provide any DOM manipulation utilities, polyfills, or interaction with actual DOM elements.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `ELEMENT_NODE` is treated as a numeric constant, not a callable function. Verify correct import syntax for your module environment (ESM `import { ELEMENT_NODE }` or CJS `const { ELEMENT_NODE } = require`).","cause":"Attempting to call an imported constant as if it were a function, or a bundler/runtime misinterpreting the export type, often due to mixed ESM/CJS environments.","error":"TypeError: (0 , dom_node_types__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_NODE) is not a function"},{"fix":"Add the appropriate import statement at the top of your file. For ESM: `import { ELEMENT_NODE } from 'dom-node-types';`. For CommonJS: `const { ELEMENT_NODE } = require('dom-node-types');`.","cause":"The constant `ELEMENT_NODE` was used without being correctly imported or destructured from the `dom-node-types` package.","error":"ReferenceError: ELEMENT_NODE is not defined"}],"ecosystem":"npm"}