{"library":"please-upgrade-node","title":"Node.js Version Upgrade Prompt","description":"Please-upgrade-node is a focused utility designed to display a clear, beginner-friendly message to users when their Node.js version does not meet the minimum requirement specified in a project's `package.json` `engines.node` field. Instead of generic stack traces, it provides actionable advice to upgrade Node.js. The package is currently at version 3.2.0, with a recent update adding TypeScript definitions, indicating active maintenance. It is specifically built for CLI applications to enhance user experience by gracefully handling Node.js version incompatibilities. A key differentiator is its strict support for only the `>=` operator in the `engines.node` field, simplifying configuration while ensuring explicit minimum version requirements. Its release cadence is sporadic, tied to feature additions or bug fixes, rather than a fixed schedule.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install please-upgrade-node"],"cli":null},"imports":["const pleaseUpgradeNode = require('please-upgrade-node');\npleaseUpgradeNode(pkg);","import type { pleaseUpgradeNodeOptions } from 'please-upgrade-node';","const pleaseUpgradeNode = require('please-upgrade-node');\npleaseUpgradeNode(pkg, { exitCode: 0, message: (v) => `Need Node ${v}` });"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nconst pkgPath = path.join(process.cwd(), 'package.json');\nconst pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));\n\n// Create a dummy package.json for demonstration if it doesn't exist\nif (!fs.existsSync(pkgPath)) {\n  fs.writeFileSync(pkgPath, JSON.stringify({\n    name: 'my-cli-app',\n    version: '1.0.0',\n    engines: {\n      node: '>=18'\n    }\n  }, null, 2));\n  console.log('Created a dummy package.json with engines.node >=18');\n}\n\n// IMPORTANT: Must run BEFORE requiring any other modules that might use newer Node.js features\nrequire('please-upgrade-node')(pkg, {\n  message: (requiredVersion) => `\\n🚧 Oh no! This application requires Node.js ${requiredVersion} or higher.\\n   You are currently running Node.js ${process.version}.\\n   Please upgrade your Node.js version to continue.\\n`,\n  exitCode: 1 // Default behavior is to exit with code 1\n});\n\n// If Node.js version is sufficient, continue with your application logic\nconsole.log(`\n🎉 Node.js version ${process.version} is sufficient. Running application...\\n`);\n// Your actual application code would follow here\n\n","lang":"typescript","description":"This example demonstrates how to install and integrate `please-upgrade-node` at the very beginning of a CLI application to ensure the user's Node.js version meets the `engines.node` requirement from `package.json`, showing a custom message and exiting if not met.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}