{"id":15147,"library":"node-exports-info","title":"Node Exports Info","description":"node-exports-info is a utility library providing programmatic access to detailed information about Node.js's `exports` field support across different Node.js versions. It helps developers understand which `exports` features, such as conditions, patterns, and pattern trailers, are available in specific Node.js environments. The library categorizes Node.js versions into distinct groups based on their `exports` implementation, including 'pre-exports', 'broken', 'experimental', 'conditions', and various pattern-related categories. This is crucial for authors of libraries and applications needing to ensure correct module resolution and interoperability across a wide range of Node.js versions, particularly given the evolving landscape of ESM and CJS module systems. Currently at version 1.6.0, it is actively maintained with updates likely correlating to significant changes in Node.js's module resolution behavior. Its primary differentiator is providing a comprehensive and version-specific mapping of `exports` capabilities, simplifying compatibility concerns for complex `package.json` `exports` configurations.","status":"active","version":"1.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/inspect-js/node-exports-info","tags":["javascript","node","exports","support","info","ranges","categories","conditions","patterns"],"install":[{"cmd":"npm install node-exports-info","lang":"bash","label":"npm"},{"cmd":"yarn add node-exports-info","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-exports-info","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally for parsing and comparing Node.js version ranges to determine exports field support categories.","package":"semver","optional":false}],"imports":[{"note":"Each utility function within `node-exports-info` is exposed as a default export from its dedicated subpath. Named imports from the root package or incorrect subpaths will not work.","wrong":"import { getCategory } from 'node-exports-info'; // Incorrect: not a named export from the root package","symbol":"getCategory","correct":"import getCategory from 'node-exports-info/getCategory';"},{"note":"For CommonJS environments, the correct way to import these default-exported subpath modules is `const getCategoriesForRange = require('node-exports-info/getCategoriesForRange');` directly, without destructuring.","wrong":"const getCategoriesForRange = require('node-exports-info').getCategoriesForRange; // Incorrect: attempting to access as a named CommonJS export from root","symbol":"getCategoriesForRange","correct":"import getCategoriesForRange from 'node-exports-info/getCategoriesForRange';"},{"note":"Ensure to use a default import (e.g., `import aliasName from 'module-path';`) for functions imported from their specific subpaths, rather than named destructuring imports.","wrong":"import { getCategoryInfo } from 'node-exports-info/getCategoryInfo'; // Incorrect: it's a default export, not a named one from the subpath","symbol":"getCategoryInfo","correct":"import getCategoryInfo from 'node-exports-info/getCategoryInfo';"}],"quickstart":{"code":"import getCategory from 'node-exports-info/getCategory';\nimport getCategoryInfo from 'node-exports-info/getCategoryInfo';\nimport getRangePairs from 'node-exports-info/getRangePairs';\n\n// Get the exports category for the current Node.js version\nconst currentCategory = getCategory();\nconsole.log(`Current Node.js exports category: ${currentCategory}`);\n\n// Get detailed info for a specific category, e.g., 'patterns'\nconst patternInfo = getCategoryInfo('patterns');\nconsole.log('\\nInfo for 'patterns' category:');\nconsole.log(JSON.stringify(patternInfo, null, 2));\n\n// Get info for the current category, specifically for 'require' module system\nconst currentCategoryRequireInfo = getCategoryInfo(currentCategory, 'require');\nconsole.log(`\\nCurrent category ('${currentCategory}') flags for 'require':`);\nconsole.log(JSON.stringify(currentCategoryRequireInfo.flags, null, 2));\n\n// List all categories with their associated semver ranges\nconsole.log('\\nAll exports categories and their Node.js version ranges:');\ngetRangePairs().forEach(([range, category]) => {\n  console.log(`- ${category}: ${range}`);\n});","lang":"typescript","description":"Demonstrates how to identify the current Node.js exports category, retrieve detailed feature flags for specific categories or module systems, and list all known categories with their corresponding Node.js version ranges."},"warnings":[{"fix":"Consult the official Node.js documentation for `package.json` `exports` alongside this library's output to fully understand complex scenarios. Use the `getCategoryInfo` and `getCategoryFlags` functions to programmatically check for specific feature support.","message":"The library reflects the highly nuanced and sometimes inconsistent behavior of Node.js `exports` field across different versions. Developers should carefully interpret the category information and flags, especially when targeting older or experimental Node.js releases, as the `exports` specification evolved considerably.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use the full subpath for each function as listed in the 'Entry points' section of the documentation. Example: `import getCategory from 'node-exports-info/getCategory';`","message":"When importing specific utility functions, ensure you use the exact subpath import as documented (e.g., `import getCategory from 'node-exports-info/getCategory'`). Direct named imports from the main package or incorrect subpaths will result in `Module not found` or `undefined` errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Change the import statement to target the specific subpath for the desired function using a default import, e.g., `import getCategory from 'node-exports-info/getCategory';`","cause":"Attempting a named import from the main package path or an incorrect subpath, but individual functions are exposed as default exports via specific subpaths.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'node-exports-info' in ..."},{"fix":"Verify that the import statement correctly uses the `default` import syntax for the specific subpath of the function you intend to use. For example, `import getCategoryInfo from 'node-exports-info/getCategoryInfo';`","cause":"Incorrectly importing a function or attempting to use a function that was not correctly imported as a default export from its specific subpath.","error":"TypeError: Cannot read properties of undefined (reading 'flags') OR 'getCategoryInfo is not a function'"}],"ecosystem":"npm"}