Search code examples
node.jswindowsnvm

Is it possible to integrate a pre-existing Node.js version with nvm?


I had previously installed Node.js version 20.2.0 directly without utilizing an nvm (Node Version Manager). However, I now desire to incorporate this existing Node.js installation into nvm without the need for reinstalling the same version using nvm. In other words, I want to include the already installed Node.js version into nvm.

I searched on the internet but found nothing.


Solution

  • I had previously installed Node.js version 20.2.0 directly without utilizing an nvm (Node Version Manager). However, I now desire to incorporate this existing Node.js installation into nvm without the need for reinstalling the same version using nvm.


    I had the same issue with nvm-windows. In my case, I needed Node.js 8.9.4 for an old program, a new version of Node.js for a new program, and didn't want to risk uninstalling the old version.


    Solution

    1. I renamed my Node.js directory from C:\Program Files\nodejs to C:\Program Files\nodejs 8.9.4
    2. I renamed C:\Users\<username>\AppData\Roaming\npm to C:\Users\<username>\AppData\Roaming\npm for Nodejs 8.9.4. This step may not be necessary.
    3. I installed nvm-windows.
    4. I verified I could still use Node.js 8.9.4 by running
    c:\Users\<username>\source\repos>nvm use 8.9.4
    Now using node v8.9.4 (64-bit)
    
    c:\Users\<username>\source\repos>node -v
    v8.9.4
    
    1. I changed C:\Users\<username>\AppData\Roaming\npm for Nodejs 8.9.4 back to its original name C:\Users\<username>\AppData\Roaming\npm

    2. I installed Node.js 20.12.2 with nvm install 20.12.2 and told nvm to use it with nvm use 20.12.2

    3. Then I could install all the other things I needed for my new project :-)