When working with Node.js development environments, flexibility is key. The Node Version Manager (NVM) is a powerful tool that lets developers easily install and manage multiple versions of Node.js on a single system. However, there are times when you might need to install a custom version of NVM or Node.js in your virtual machine— for example, a forked version for testing, a version with patched features, or an older revision not available in the main NVM registry.
In this article, we’ll walk through the steps to install a custom version of NVM and then use it to install a custom or local version of Node.js.
There are several use cases for installing a custom version:
Testing patches or forks of NVM or Node.js.
Using Node.js builds with experimental features.
Working offline with locally compiled versions.
Compatibility with legacy projects requiring specific environments.
If you’re working with a fork or custom branch of NVM:
Then, add NVM to your shell configuration:
If you’re using zsh, replace .bashrc with .zshrc.
✅ Tip: Test the installation by running nvm –version.
If you have a custom version of Node.js built from source:
Clone the Node.js repository or your custom fork:
Compile and install it locally:
Use NVM to “install” this version:
Then, manually symlink your local build:
If you have a precompiled Node.js tarball:
Then use it as normal:
nvm not found: Ensure the path to NVM is correctly added in your shell configuration.
Permission issues: Use sudo cautiously. NVM and Node.js are designed to run without elevated privileges.
Compilation errors: Ensure all build dependencies are installed (build-essential, python, etc.).
Installing a custom version of NVM or Node.js gives you fine-grained control over your development environment. Whether you’re testing experimental features or working on a legacy system, these custom setups are invaluable. By following the steps above, you can create a robust and tailored Node.js development workflow suited to your needs.