When attempting to install node version 8.9.4 with NVM for windows, I received an error when it attempted to install npm, indicating that a file name was too long. There are a number of GitHub issues related to this, with many suggestions; some involving moving files around, some suggesting deleting files. In many cases, these solutions didn’t work. I found the solutions overly complex.
My solution is fairly simple:
- Run “nvm root c:\nvm-windows”
- Copy elevate.cmd and elevate.vbs from c:\Users\<username>\AppData\Roaming\nvm to c:\nvm-windows
- Copy vXXX versions of node from c:\Users\<username>\AppData\Roaming\nvm to c:\nvm-windows
- This is optional, and only if you want to preserve your old versions of node
- Run “nvm install 8.9.4”
This solution changes the directory that NVM stores its versions of node. The default path that nvm stores different versions of node is lengthy. If you move it to a path closer to c: then NVM doesn’t have problems with file names being too long while installing.