So you want to use NodeJS on a portable flash drive?
Or maybe just in a non-restricted directory?
If you are reading this then you may have gone through the following as I have.
Attempted to use NodeJS Portable by Crazy Max which fails due to the company proxy server and not being able to set the proxy before the installation of Node.
Attempted to use NodeJS Portable by Gareth Flowers which installs correctly but the Node version is too outdated to use ReactJS or similar frameworks.
Attempted to use nvm-windows which after following the instructions given in the README doesn't work because
nvm use 13.8.0
requires you to enter a username and password for Window's User Account Control.
If you are still reading then here is my working (very hacky) solution to get NodeJS portable!
I used a portable version of Cmder but I imagine any terminal program where you can add to the PATH is fine.
- Install Cmder in your desired location.
- Download
nvm-noinstall.zip
from the latest release. - Extract the contents of
nvm-noinstall.zip
into thebin
folder inside of the portable Cmder folder. - Navigate to the
bin
folder in Cmder and runinstall.md
- When asked to enter the absolute path use your Cmder
bin
folder. (In my case, for some reason thesettings.txt
isn't created in thebin
folder but instead is made at root of my usb i.e.E:/
). - Install the version of node you want i.e.
nvm install latest
(Make sure to still be inside of thebin
folder in your terminal program). - Wait until
node
andnpm
have finished installing. - Inside the
bin
folder there should be a folder containing the latest node version e.g.v13.8.0
. - Copy the absolute path to that folder. e.g.
E:\PortableApps\CmderPortable\bin\v13.8.0
. - Add this to your existing path in Cmder's environment settings. e.g.
set "PATH=E:\PortableApps\CmderPortable\bin\v13.8.0;%PATH%"
- Make sure you are still inside your
bin
folder. Runnvm use v13.8.0
or your chosen node version. You can close the username and password window both times without entering anything. It should tell youNow using node v13.8.0 (64-bit)
. - Close and open Cmder and you should have access to
node
,npm
andnpx
😄.
I have also posted this information on the nvm-windows issue requesting for a portable version #363
Let me know if you have any alternative solutions. I would be happy to read them in the comments.
Happy coding! 🥳
P.S. I'd like to start the habit of sharing the music that I am listening to while writing up my posts. Today's music is a part of a set by South African super collector DJ Okapi. Check it out here. https://www.mixcloud.com/radioradioradioradio/dj-okapi-radio-radio/
Top comments (10)
Thanks William.
I would like to point out a few things:
I modified mine as blow if anyone interested:
@echo off
set /P NVM_PATH="Enter the absolute path where the zip file is extracted/copied to: "
setx NVM_HOME "%NVM_PATH%"
set NVM_SYMLINK=C:\Program Files\nodejs
setx NVM_SYMLINK "%NVM_SYMLINK%"
setx PATH "%PATH%;%NVM_PATH%;%NVM_SYMLINK%"
if exist "%SYSTEMDRIVE%\Program Files (x86)\" (
set SYS_ARCH=64
) else (
set SYS_ARCH=32
)
(echo root: %NVM_PATH% && echo path: %NVM_SYMLINK% && echo arch: %SYS_ARCH% && echo proxy: none) > %NVM_PATH%\settings.txt
@echo on
Lifesaver!
Thanks, William, for great walk-through, unfortunately I stuck at step 5. Installer stubbornly want to create c:/settings.txt, no matter what i input during installation or even in install.cmd file. There is no other than C:/ on computer I am using right now and I don't have administrator permissions here.
Hey Dainius, assuming you are wanting to install onto a usb, are you running your command line program from your usb and not from your regular Programs? Basically when you run your terminal from a portable program only that usb (E:/) will be in your path and not the C drive.
The only other thing I can think of is check if nvm can run even if settings.txt isn't made correctly. If it does then use
nvm root
to change the nvm PATH to your USB. Then you should be able to move the settings.txt file.Hi, William,
actually I'm installing in some folder in c:/ disk. Will try the USB option then. Thanks for your answer.
I have node.js working on my usb (and windows10 laptop), currently if I remove the usb and then re-insert I have to restart the node server - I use 'pm2' to start, stop etc. I'd like the node server to restart when I insert the usb - how do I do that? I should add I have pm2 installed globally - it resides on my c drive on laptop.
Hey William, feel free to open an issue or a PR to enhance nodejs-portable :)
github.com/crazy-max/nodejs-portable/
But overall nvm-windows is more complete :)
Hey Max, I don't have any Go experience unfortunately but if I ever get into Go I'll look into it :)
Hi, I tried this one with hope but I get the error message "Access to the registry path is denied" after running install.cmd 😕
Hi, sorry for the late response. I don't know much about the Windows registry unfortunately. Are you trying to install on a USB or your C drive? My solution only works if you do everything on the USB.