7

I have no admin rights in my windows machine. Can I install NVM without admin rights? I tried using the environment variable path setup, but its not working in my case.

James Z
  • 12,209
  • 10
  • 24
  • 44
Sandra Pavan
  • 194
  • 1
  • 2
  • 8

5 Answers5

5

(You're talking about https://github.com/coreybutler/nvm-windows right?)

Whether you can install it without admin rights aside, the actual act of switching node versions with it requires them so you're going to have trouble.

Your best bet is to install different versions of node into different paths manually, and then configure your environment variables to point to the right one whenever you need to use it.

eg. prefix your cmd script with PATH=C:\node\v10;%PATH% to have any node or npm calls in that script use whatever node is sitting in v10

Bligglenuber
  • 224
  • 1
  • 5
  • There isn't any reason if it was designed to use local pc variables and not use the registry. PATH=C:\node\v10;%PATH% doesn't require admin rights if you "edit environment variables for your user account" instead of "edit system environment variables". So long as you install node and npm to a directory that is not "program files", such as c:\programs\nodejs and c:\programs\nvm. Same goes for linux using home path and editing a users rc-update.sh. If you run as admin mode, it should install as admin mode. Otherwise, local user mode. Guess it isn't supported. But it is open source. Needs changed – TamusJRoyce Jun 19 '19 at 17:35
  • You can use `volta` instead of `nvm`. It creates a shim that can switch node versions on the fly without any admin rights. – Muhammad bin Yusrat Sep 02 '22 at 02:12
5

I have the same need and couldn't find one, so I created one base on another simple nvm:

https://www.npmjs.com/package/@jchip/nvm

Requires powershell 4+ and permission to execute scripts.

Joel Chen
  • 270
  • 3
  • 7
0

try this

create a bat file like below

@cd C:\Users\testuser\AppData\Roaming\nvm

@SET PATH=C:\Users\testuser\AppData\Roaming\nvm\v14.21.1;%PATH%

cd c:\users\testuser\Desktop\Project

@cmd.exe /K

Run bat file and type

code .

It's open with VSCode

go to the terminal and type node and you can see the node version that you set in the bat file.

enter image description here

You can apply any node version as above bat file

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0

NVM's drawback is that it requires administrative rights to transition between node versions. When you work for a corporate, it could be difficult to obtain it. I advise copying the NVM folder to any folder that the user has access to. (Alternatively, obtain several Node versions for Windows from a different source). Add the profile.ps1 file to the location specified.

C:\Users\<user>\Documents\WindowsPowerShell\profile.ps1

Change the directory path and then paste these lines into the file.

# $env:PATH += ";C:\Users\<user>\Documents\nvm\v14.21.3"

$env:PATH += ";C:\Users\<user>\Documents\nvm\v16.20.1"

# $env:PATH += ";C:\Users\<user>\Documents\nvm\v18.17.0"

# $env:PATH += ";C:\Users\<user>\Documents\nvm\v20.5.0"

Execute the line given below in "PowerShell" after that. Execution should be from "C:\Users\<user>\Documents\WindowsPowerShell" directory only. This is for obtaining the necessary rights to run the "profile.ps1" file.

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

This file acts like a ".bashrc" file in unix systems. Therefore, it will run each time you open PowerShell and contains the uncommented node version.

Arjun G
  • 2,194
  • 1
  • 18
  • 19
-1

If you use Git Bash on Windows, you can add this to your bash.bashrc to switch node versions:

export PATH=/c/path/to/node/dir:$PATH

Then just restart your terminal to pick up the updated PATH.

It will prepend your path with your desired node version. It's the only way I've found to override the installed node version if you don't have admin rights on your machine.

brt
  • 154
  • 1
  • 2
  • 12