| name | nodapt |
| description | Use this skill to execute commands when a user requests to run nodejs/npm commands, and you can specify the desired nodejs version. |
Nodapt
nodapt is a virtual Node.js environment designed to provide a simple and reliable version management tool for Node.js projects. It can automatically select and install the appropriate version of Node.js based on the version constraints in package.json and run commands.
If your package.json file contains Node.js version constraints, or if the user explicitly requests to run Node.js with a specific version or manage installed versions, then you should use this skill to run the command.
If the user requests to use or remove a specific Node.js version but does not provide a valid version format, ask the user to clarify the desired version before executing the command.
If the user does not have nodapt installed, you can suggest them to install it using the instructions in the Installation section below.
When to Use This Skill
Use this skill when:
- Running any Node.js or npm command in a project
- The project's
package.json specifies a Node.js version in engines.node
- The user explicitly requests a specific Node.js version
- Managing (installing, removing, listing) Node.js versions
- The user mentions "nodapt" or asks about Node.js version management
Basic Usage Patterns
1. Automatic Version Selection
Run commands with the Node.js version specified in package.json:
nodapt node -v
nodapt npm install
nodapt npx create-react-app my-app
2. Specify Node.js Version
Use a specific Node.js version for a command:
nodapt use v14.17.0 node app.js
nodapt use 22 node script.js
nodapt use ^16.14.0 npm test
3. Version Management Commands
List installed versions:
nodapt ls
List available remote versions:
nodapt ls-remote
Remove a specific version:
nodapt rm v14.17.0
Clean all installed versions:
nodapt clean
Common Scenarios
Scenario 1: Running a Project with Version Constraints
When a user asks to run a project, first check if package.json exists and has Node.js version constraints:
{
"engines": {
"node": ">=16.0.0 <19.0.0"
}
}
nodapt npm start
Scenario 2: Testing Across Node.js Versions
When a user needs to test code with different Node.js versions:
nodapt use 14 npm test
nodapt use 16 npm test
nodapt use 18 npm test
Scenario 3: Global Tool Installation
Install tools without affecting the system Node.js:
nodapt npm install -g yarn
nodapt yarn build
Error Handling
Version Not Found
If the specified version is not available:
$ nodapt use v14.17.0 node -v
Error: Version v14.17.0 not found
nodapt ls-remote | grep 14.17
Invalid Version Format
If the user provides an invalid version format, ask for clarification:
No Compatible Version Found
When auto-detection fails:
$ nodapt node -v
Error: No compatible Node.js version found for engines.node: ">=99.0.0"
Installation Instructions
Method 1: Using Cask (Recommended)
$ cask install github.com/axetroy/nodapt
Method 2: Using npm
$ npm install -g nodapt
Method 3: Manual Installation
Check the source repository for binary releases.
Verify Installation
nodapt --version
Configuration
Environment Variables
Set custom Node.js mirror (useful in China):
export NODE_MIRROR="https://registry.npmmirror.com/-/binary/node/"
Set custom installation directory:
export NODE_ENV_DIR="/custom/path/.nodapt"
Enable debug output:
export DEBUG=1
nodapt node -v
Best Practices
-
Always check for package.json: Before running commands with nodapt, check if the project has a package.json with Node.js version constraints.
-
Use version ranges wisely: When specifying versions, use semantic versioning ranges (e.g., ^16.14.0, >=14.0.0 <17.0.0).
-
Prefer automatic selection: Let nodapt auto-detect the version from package.json when possible.
-
Clean up old versions: Periodically run nodapt clean to remove unused Node.js versions and free disk space.
-
Specify exact versions in CI/CD: In automated environments, always specify exact versions to ensure reproducibility.
Troubleshooting
Issue: Command not found
which nodapt
npm install -g nodapt
Issue: Permission denied
ls -la $(which nodapt)
npm config set prefix ~/.npm-global
export PATH=~/.npm-global/bin:$PATH
npm install -g nodapt
Issue: Slow downloads
export NODE_MIRROR="https://registry.npmmirror.com/-/binary/node/"
nodapt node -v
Examples in Conversation
User: "Run my Node.js app"
nodapt node app.js
User: "Test with Node.js 18"
nodapt use 18 npm test
User: "Install dependencies"
nodapt npm install
User: "Which Node.js versions do I have installed?"
nodapt ls
User: "Remove Node.js 14"
nodapt rm v14.17.0
Help Command
For complete help information:
nodapt --help
This displays all available commands, options, and examples.
Source Code
Find the source code and report issues at:
https://github.com/axetroy/nodapt