Registry / devops / is-node-modern

is-node-modern

JSON →
library1.0.0jsnpmunverified

This package, `is-node-modern`, provides a utility to programmatically or via CLI determine if the current Node.js environment meets a specified "modern" version threshold. It's currently at version 1.0.0, released during an era when Node.js versions 0.10 through 6.x were prevalent. While it allows for custom version thresholds, its default "modern" check is based on outdated LTS definitions, rendering it largely irrelevant for contemporary Node.js development without explicit configuration. Given its initial and sole release, along with the age of the Node.js versions it was designed for, the package is considered abandoned, lacking ongoing maintenance or updates for modern Node.js ecosystems. It offers a simple programmatic API (`require('is-node-modern')`) and a CLI command (`is-node-modern`) primarily for conditional execution in `package.json` scripts.

npm install is-node-modern
INSTALL
IMPORT
SIG · IS-NODE-MODERN
I
is-node-modern
devopsjavascriptv1.0.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.

isNodeModern
const isNodeModern = require('is-node-modern');
import { isNodeModern } from 'is-node-modern'; import isNodeModern from 'is-node-modern';
This package is CommonJS-only and exports a single function as its module.exports. It does not support native ES Module (ESM) imports.

Demonstrates both programmatic and conceptual CLI usage of `is-node-modern`, highlighting the need to specify a modern version threshold due to the package's outdated defaults.

const isNodeModern = require('is-node-modern'); // Check if the current Node.js version is considered modern by the package's default threshold. // WARNING: This default is based on very old Node.js LTS versions (e.g., v4 or v6) and will // likely return false for genuinely modern Node.js versions (e.g., Node.js 18+). if (isNodeModern()) { console.log(`Node.js ${process.versions.node} is considered modern by the default (outdated) definition.`); } else { console.log(`Node.js ${process.versions.node} is NOT considered modern by the default definition.`); } // To check against a specific, more relevant Node.js version (e.g., Node.js 16 or newer) const MIN_MODERN_VERSION = 16; if (isNodeModern(MIN_MODERN_VERSION)) { console.log(`Node.js version ${process.versions.node} is at or above v${MIN_MODERN_VERSION}.`); // Example: Execute a task or load a module only if Node.js is modern enough // try { // const { someModernFeature } = require('some-modern-only-lib'); // someModernFeature(); // } catch (error) { // console.error('Failed to use modern feature:', error.message); // } } else { console.log(`Node.js version ${process.versions.node} is below v${MIN_MODERN_VERSION}. Skipping modern-only actions.`); } console.log('\n--- CLI Usage Example (typically in package.json scripts) ---'); console.log('// In your package.json, under "scripts":'); console.log('// "my-action": "is-node-modern 18 && echo \"Running modern action (Node 18+)\" || echo \"Skipping, Node version too old\""'); console.log(`// Current Node version: ${process.versions.node}`); console.log('// If Node.js >= 18, the first command runs. Otherwise, the second runs.');
is-node-modern --version
Debug
Known issues
gotchaThe package's default definition of 'modern' Node.js is based on LTS versions from around the Node.js 4.x-6.x era (circa 2016-2018). Using `isNodeModern()` programmatically or `is-node-modern` without a specific version argument will likely result in false negatives for genuinely modern Node.js runtimes (e.g., Node.js 16+).
fix
Always explicitly specify a version threshold for modern Node.js environments, e.g., `isNodeModern(18)` in code or `is-node-modern 18` in CLI scripts.
affects: >=1.0.0
breakingThis package is at its initial v1.0.0 release and appears to be unmaintained. Its build badges reference Node.js versions 0.10-6.x, indicating it was developed and last updated almost a decade ago. It is considered abandoned.
fix
Avoid using this package for new projects. For existing projects, evaluate migrating to custom Node.js version checks (e.g., `parseInt(process.versions.node) >= 18`) or more current environment detection tools, especially for production systems.
affects: >=1.0.0
gotchaThe package exclusively uses CommonJS (`require`). There is no native ES Module (ESM) support, and attempting to `import` it directly in an ESM context will lead to errors without a transpilation step or a CommonJS wrapper.
fix
Ensure you are using CommonJS `require('is-node-modern')` in your JavaScript files, or configure your build process to handle CommonJS modules within an ESM project.
affects: >=1.0.0
Errors
Common errors & fixes
is-node-modern: command not found
The `is-node-modern` executable is not in the system's PATH or `npm run` context, typically because it wasn't installed or installed incorrectly.
fix
Ensure `is-node-modern` is listed in your `devDependencies` in `package.json` and executed via `npm run <script-name>`. For global CLI usage (generally discouraged for project dependencies), install it with `npm install -g is-node-modern`.
TypeError: isNodeModern is not a function
Attempting to use `isNodeModern` as a named export or assuming it's an object with methods, or trying to `import isNodeModern from 'is-node-modern'` in an ES Module context.
fix
Use the CommonJS `require` syntax: `const isNodeModern = require('is-node-modern');` and call it as a default function: `if (isNodeModern())` or `if (isNodeModern(16))`.
Unexpected behavior: `is-node-modern` (without argument) reports Node.js 18 as *not* modern.
The package's internal default threshold for 'modern' is based on Node.js LTS versions from approximately 2016-2018 (e.g., v4 or v6), which are now very old.
fix
Always provide a specific version threshold as an argument for current Node.js versions, e.g., `is-node-modern 18` in the CLI or `isNodeModern(18)` in your code.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
is-node-modern — npm install is-node-modern · libregistry