UNPKG

nvmrc-wizard

Version:

Automatically generate and manage .nvmrc based on your framework's Node.js compatibility

80 lines (56 loc) • 1.97 kB
# nvmrc-wizard šŸš€ Automatically generate and manage `.nvmrc` based on your framework's Node.js compatibility. Supports **Angular**, **React**, and **Vue** with comprehensive compatibility matrices. ## Features - āœ… Auto-detects your framework and version - āœ… Recommends the most compatible Node.js version - āœ… Creates or updates `.nvmrc` file - āœ… Optionally switches Node version using NVM - āœ… Works on Windows, macOS, and Linux - āœ… Shows NVM installation guide if needed if nvm is not installed ## Usage ```bash # Run in your project directory npx nvmrc-wizard ``` ## What it does 1. **Detects your framework** from `package.json` (Angular/React/Vue) 2. **Finds the most compatible Node.js version** based on your framework version 3. **Creates `.nvmrc`** if it doesn't exist 4. **Prompts to update** if `.nvmrc` exists but has a different version 5. **Switches to the recommended version** (if NVM is installed and you confirm) ## Example output ``` šŸ” Analyzing Node.js version compatibility... šŸ“¦ Detected: Angular v17.2.0 šŸŽÆ Most compatible Node.js version: v20.19.1 šŸ“„ No .nvmrc file found. āœ… Created .nvmrc with recommended Node.js v20.19.1 šŸ”„ Switching to Node.js v20.19.1 as specified in .nvmrc... āœ… Successfully switched to Node.js v20.19.1 ``` ## Supported Frameworks - **Angular** 13.x - 20.x - **React** 14.x - 19.x - **Vue** 2.6.x - 3.5.x For native JavaScript projects, it uses the latest LTS version. ## Requirements - Node.js >= 14 - (Optional) NVM for automatic version switching ## Use with Husky Add to `.husky/pre-commit`: ```bash #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" # Guid to auto-generate .nvmrc if missing if [ ! -f .nvmrc ]; then echo "āŒ ERROR: .nvmrc file is missing!" echo "" echo "šŸ“‹ Please create .nvmrc by running:" echo " npx nvmrc-wizard" echo "" exit 1 fi ``` ## License MIT