Registry / devops / node-exports-info

node-exports-info

JSON →
library1.6.0jsnpmunverified

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.

npm install node-exports-info
INSTALL
IMPORT
SIG · NODE-EXPORTS-INFO
N
node-exports-info
devopsjavascriptv1.6.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.

getCategory
import getCategory from 'node-exports-info/getCategory';
import { getCategory } from 'node-exports-info'; // Incorrect: not a named export from the root package
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.
getCategoriesForRange
import getCategoriesForRange from 'node-exports-info/getCategoriesForRange';
const getCategoriesForRange = require('node-exports-info').getCategoriesForRange; // Incorrect: attempting to access as a named CommonJS export from root
For CommonJS environments, the correct way to import these default-exported subpath modules is `const getCategoriesForRange = require('node-exports-info/getCategoriesForRange');` directly, without destructuring.
getCategoryInfo
import getCategoryInfo from 'node-exports-info/getCategoryInfo';
import { getCategoryInfo } from 'node-exports-info/getCategoryInfo'; // Incorrect: it's a default export, not a named one from the subpath
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.

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.

import getCategory from 'node-exports-info/getCategory'; import getCategoryInfo from 'node-exports-info/getCategoryInfo'; import getRangePairs from 'node-exports-info/getRangePairs'; // Get the exports category for the current Node.js version const currentCategory = getCategory(); console.log(`Current Node.js exports category: ${currentCategory}`); // Get detailed info for a specific category, e.g., 'patterns' const patternInfo = getCategoryInfo('patterns'); console.log('\nInfo for 'patterns' category:'); console.log(JSON.stringify(patternInfo, null, 2)); // Get info for the current category, specifically for 'require' module system const currentCategoryRequireInfo = getCategoryInfo(currentCategory, 'require'); console.log(`\nCurrent category ('${currentCategory}') flags for 'require':`); console.log(JSON.stringify(currentCategoryRequireInfo.flags, null, 2)); // List all categories with their associated semver ranges console.log('\nAll exports categories and their Node.js version ranges:'); getRangePairs().forEach(([range, category]) => { console.log(`- ${category}: ${range}`); });
Debug
Known issues
gotchaThe 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.
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.
affects: >=1.0.0
gotchaWhen 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.
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';`
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'node-exports-info' in ...
Attempting a named import from the main package path or an incorrect subpath, but individual functions are exposed as default exports via specific subpaths.
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';`
TypeError: Cannot read properties of undefined (reading 'flags') OR 'getCategoryInfo is not a function'
Incorrectly importing a function or attempting to use a function that was not correctly imported as a default export from its specific subpath.
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';`
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies
semverrequiredUsed internally for parsing and comparing Node.js version ranges to determine exports field support categories.
Agent activity
4 hits · last 30 days
node
4
Resources
node-exports-info — npm install node-exports-info · libregistry