Skip to content

Instantly share code, notes, and snippets.

@massahud
Last active November 7, 2024 12:45
Show Gist options
  • Save massahud/321a52f153e5d8f571be to your computer and use it in GitHub Desktop.
Save massahud/321a52f153e5d8f571be to your computer and use it in GitHub Desktop.
Portable Node.js and NPM on windows
  1. Get node binary (node.exe) from http://nodejs.org/download/
  2. Create the folder where node will reside and move node.exe to it
  3. Download the last zip version of npm from http://nodejs.org/dist/npm
  4. Unpack the zip inside the node folder
  5. Download the last tgz version of npm from http://nodejs.org/dist/npm
  6. Open the tgz file and unpack only the file bin/npm (without extension) directly on the node folder.
  7. Add the the node folder and the packages/bin folder to PATH
  8. On a command prompt execute npm install -g npm to update npm to the latest version

Now you can use npm and node from windows cmd or from bash shell like Git Bash of msysgit.

@xyberviri
Copy link

xyberviri commented Apr 30, 2024

@WillRubin Oh your right i didnt really notice that because my requirement were run and then delete off of a windows server with out leaving stuff configured, I'm assuming this is for a thumb drive so you can try the following:

Set the thumb drive letter to something that will NOT change between systems like P otherwise stuff breaks

extract the zip files to that drive in the location you want node.js like before im going to assume P:\node-v22.0.0-win-x64\

edit the 4th line of nodevars.bat from set "PATH=%APPDATA%\npm;%~dp0;%PATH%" to set "PATH=%~dp0;%PATH%"

then open a new command prompt and type cd /d P:\node-v22.0.0-win-x64\

then npm install npm@latest that should throw everything into P:\node-v22.0.0-win-x64\ i have zero clue what the repercussions of doing this are but stuff seems to work.

when you open a command prompt and type P:\node-v22.0.0-win-x64\nodevars.bat it should add P:\node-v22.0.0-win-x64\ to your systems %PATH% for that command prompt session.

if stuff breaks try installing npm in a different location it just uses whatever folder you are in unless you use -g in which case it uses %appdata% you can override this with --prefix ./ but that location has to be in your path for stuff to work

@jeanniton-mnr
Copy link

It's 2023 - save yourself some time...

Download and run: https://github.com/crazy-max/nodejs-portable/releases/download/2.10.0/nodejs-portable.exe

Node.js Portable 2.10.0
https://github.com/crazy-max/nodejs-portable

# Menu
 1 - Install
 2 - Shell

* Type 'exit' to leave Node.js Portable

'menu' for help>
  • Press [1] and [Enter]
  • Press [Enter] (or first enter Node version you want)
  • Press [Enter] (or 'x64' for 64bit version)
  Version (default 19.4.0):
  Architecture (default x86):

Checking Node.js version 19.4.0... OK!
Downloading https://nodejs.org/dist/v19.4.0/node-v19.4.0-win-x86.zip................... OK!
Extracting node-v19.4.0-win-x86.zip... OK!
Moving nodejs folder... OK!
Creating Node.js configuration... OK!


'menu' for help>
  • Type menu and [Enter]
  • Type [2] and [Enter]
  • Type [Enter]
'menu' for help> menu

# Menu
 1 - Install
 2 - Shell

* Type 'exit' to leave Node.js Portable

'menu' for help> 2

Checking if Node.js installed... OK!
Creating Node.js configuration... OK!
Checking custom paths...
# C:\Program Files (x86)\Git\cmd Warning: Not found...
# D:\another_path Warning: Not found...
# C:\apps\a_relative_path Warning: Not found...
Adding node to PATH... OK!
Setting NODE_PATH... OK!
Creating launch script... OK!

Press Enter to open the shell...

You're done!

node -v

npm -v

What your speedrun time?!

Your solution has worked for me.

Thank you!

@FahadBinHussain
Copy link

FahadBinHussain commented Oct 8, 2024

2024 updated guide created by me - https://rentry.co/node-portable

Thanks to @progmars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment