How to install Node Version Manager(NVM) without admin rights
Asked Answered
P

6

10

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.

Phonography answered 6/9, 2018 at 16:4 Comment(1)
You can use volta instead of nvm. It creates a shim that can switch node versions on the fly without any admin rights.Official
H
7

(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

Himmler answered 6/9, 2018 at 18:24 Comment(3)
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 changedMeliorate
You can use volta instead of nvm. It creates a shim that can switch node versions on the fly without any admin rights.Official
this is still require an admin access as it will ask you to install Volta using this command: winget install Volta.Volta . Not sure if there is another way to install without admin access. referring : docs.volta.sh/guide/getting-startedFlounce
S
6

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.

Seesaw answered 26/6, 2019 at 8:17 Comment(0)
M
2

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

Maquis answered 30/11, 2022 at 6:2 Comment(2)
This one worked for me. I have no admin rights using my corporate assigned laptop. But I was able to use my noinstall-nvm stored in my user folder, to my portable node stored in my user folder.Jauregui
this worked for me as well, thanks !Bases
M
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 -Scope CurrentUser -ExecutionPolicy Unrestricted

powershell -ExecutionPolicy Bypass -File .\profile.ps1

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.

Update:

Here is the link for few node version executable. https://www.mediafire.com/file/2msfjc09b81ok3v/node_versions.zip/file

Microcosm answered 27/7, 2023 at 14:5 Comment(0)
F
0

Find the node versions that you want to use on your projects and download the prebuilt binaries e.g. let me give an example we want version 18.19.1 and 10.9.0 prebuilt binaries.

enter image description here

Then the next step is create a folder somewhere in a working directory, copy the zip files there and extract them.

C:\
│
└───Users
    └───UserX
        └───Documents
            └───node-versions // Newly created directory with extracted node versions
                ├───node-v10.24.1-win-x64
                │   ├───bin
                │   ├───include
                │   ├───lib
                │   ├───share
                │   └───...
                │
                └───node-v18.19.1-win-x64
                    ├───bin
                    ├───include
                    ├───lib
                    ├───share
                    └───...

For example, you have a project which uses node 18.19.1 then navigate to the project and in the root, directory create a bat script e.g. load-node-env.bat add the following:

Windows

@echo off
set "NODE_PATH=C:\Users\UserX\Documents\nvm\node-v18.19.1-win-x64"
set "PATH=%NODE_PATH%;%PATH%"

NOTE: The path will differ depending on where the extracted node versions were extracted.

Do the same on the other project and change path.

Finbar answered 22/3 at 8:47 Comment(0)
T
-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.

Toad answered 19/11, 2020 at 21:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.