使用nvm 1.1.1安装Node.js v6.4.0报错,求排查方案
Hey there, let's figure out why you're hitting that frustrating error when trying to install Node.js v6.4.0—this version definitely exists (it launched back in July 2016), so the issue is almost certainly on the NVM side. Here are the most likely causes and fixes:
1. Your NVM version is way too outdated
NVM 1.1.1 is an extremely old release—current stable versions are in the 0.39.x range. Older NVM builds don't maintain an up-to-date list of all Node.js releases over time. That's why it can find v10.1.0 (which was added to NVM's version list before your old release stopped being updated) but can't locate v6.4.0.
Fix: Update NVM to the latest version:
- For Linux/macOS: Run the official NVM installation script to replace your old version. After running it, restart your terminal to apply the changes.
- For Windows (if using nvm-windows): Download the latest installer from the official NVM for Windows repository and run it to overwrite your existing installation.
2. Network issues are blocking NVM from fetching the full version list
Sometimes network restrictions (like corporate firewalls, DNS pollution, or slow international connections) can prevent NVM from pulling the complete, up-to-date list of Node.js versions. Even after updating NVM, this might still be a problem.
Fix: Use a reliable domestic Node.js mirror to bypass network hurdles:
Run these commands to set the mirror and try the install again:
nvm node_mirror https://npm.taobao.org/mirrors/node/ nvm install 6.4.0
3. Manually install Node.js v6.4.0 if all else fails
If updating NVM and switching mirrors doesn't work, you can manually add the version to NVM's managed versions:
- Download the Node.js v6.4.0 package matching your OS and architecture (e.g.,
.tar.gzfor Linux/macOS,.zipfor Windows). - Locate your NVM versions directory:
- Linux/macOS:
~/.nvm/versions/node/ - Windows (nvm-windows): Usually
C:\Users\YourUsername\.nvm\versions\node\
- Linux/macOS:
- Extract the downloaded package into a folder named
v6.4.0inside that directory. - Run
nvm use 6.4.0to switch to this version, then verify it works withnode -v.
Once you've got v6.4.0 up and running, consider creating a .nvmrc file in your project root with the content 6.4.0—this way NVM will automatically switch to the correct version whenever you navigate to your project folder.
内容的提问来源于stack exchange,提问作者java2017

