Sandra Pavan
Sandra Pavan

Reputation: 264

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

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.

Upvotes: 11

Views: 47359

Answers (7)

Philip Mutua
Philip Mutua

Reputation: 6891

Windows Only Solution

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 (change to the node version you want).

Do the same on the other project and change path.

Note: This option is if you are using a corporate machine and need to use different Node version. I tried using NVM, but it still requires permissions when attempting to install a different version.

Every time you want to use the node version you want just run:

load-node-env.bat

Upvotes: -1

kawai_weebster
kawai_weebster

Reputation: 151

Instead of using nvm , you can use an alternative nvs https://github.com/jasongin/nvs

nvs allows you to switch node version without admin access , but it doesnt change the node version globally instead the scope of the node version is within the current command window in which you use the nvs commands .

Upvotes: 0

Arjun G
Arjun G

Reputation: 2294

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

Upvotes: 0

Stephan Nalaka
Stephan Nalaka

Reputation: 41

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

Upvotes: 4

brt
brt

Reputation: 153

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.

Upvotes: -1

Joel Chen
Joel Chen

Reputation: 278

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.

Upvotes: 6

Bligglenuber
Bligglenuber

Reputation: 222

(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

Upvotes: 6

Related Questions