{"id":14636,"library":"is-node-modern","title":"Node.js Modern Version Detector","description":"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.","status":"abandoned","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/alexindigo/is-node-modern","tags":["javascript","node","modern","cli","tool","version"],"install":[{"cmd":"npm install is-node-modern","lang":"bash","label":"npm"},{"cmd":"yarn add is-node-modern","lang":"bash","label":"yarn"},{"cmd":"pnpm add is-node-modern","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and exports a single function as its module.exports. It does not support native ES Module (ESM) imports.","wrong":"import { isNodeModern } from 'is-node-modern';\nimport isNodeModern from 'is-node-modern';","symbol":"isNodeModern","correct":"const isNodeModern = require('is-node-modern');"}],"quickstart":{"code":"const isNodeModern = require('is-node-modern');\n\n// Check if the current Node.js version is considered modern by the package's default threshold.\n// WARNING: This default is based on very old Node.js LTS versions (e.g., v4 or v6) and will\n// likely return false for genuinely modern Node.js versions (e.g., Node.js 18+).\nif (isNodeModern()) {\n  console.log(`Node.js ${process.versions.node} is considered modern by the default (outdated) definition.`);\n} else {\n  console.log(`Node.js ${process.versions.node} is NOT considered modern by the default definition.`);\n}\n\n// To check against a specific, more relevant Node.js version (e.g., Node.js 16 or newer)\nconst MIN_MODERN_VERSION = 16;\nif (isNodeModern(MIN_MODERN_VERSION)) {\n  console.log(`Node.js version ${process.versions.node} is at or above v${MIN_MODERN_VERSION}.`);\n  // Example: Execute a task or load a module only if Node.js is modern enough\n  // try {\n  //   const { someModernFeature } = require('some-modern-only-lib');\n  //   someModernFeature();\n  // } catch (error) {\n  //   console.error('Failed to use modern feature:', error.message);\n  // }\n} else {\n  console.log(`Node.js version ${process.versions.node} is below v${MIN_MODERN_VERSION}. Skipping modern-only actions.`);\n}\n\nconsole.log('\\n--- CLI Usage Example (typically in package.json scripts) ---');\nconsole.log('// In your package.json, under \"scripts\":');\nconsole.log('// \"my-action\": \"is-node-modern 18 && echo \\\"Running modern action (Node 18+)\\\" || echo \\\"Skipping, Node version too old\\\"\"');\nconsole.log(`// Current Node version: ${process.versions.node}`);\nconsole.log('// If Node.js >= 18, the first command runs. Otherwise, the second runs.');","lang":"javascript","description":"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."},"warnings":[{"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.","message":"The 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+).","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"This 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.","severity":"breaking","affected_versions":">=1.0.0"},{"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.","message":"The 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.","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 `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`.","cause":"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.","error":"is-node-modern: command not found"},{"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))`.","cause":"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.","error":"TypeError: isNodeModern is not a function"},{"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.","cause":"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.","error":"Unexpected behavior: `is-node-modern` (without argument) reports Node.js 18 as *not* modern."}],"ecosystem":"npm"}