Dhruv Singh
Dhruv Singh

Reputation: 2243

Access Denied issue with NVM in Windows 10

I'm getting 'access is denied' when I'm using nvm -v command in windows 10. I have got the similar issue here NVM is Access Denied

But he himself gave a solution which is not working for me.

Is there any solution for this problem?

Upvotes: 185

Views: 227559

Answers (29)

Himanshu Patel
Himanshu Patel

Reputation: 63

Try to remove any existing version of Node.js which was installed via Node's official installer, winget or Chocolatey, and then retry the command in your terminal as an Administrator.

In my case, I had accidentally installed another version of Node.js using winget, which was causing conflict with NVM.

Upvotes: 0

Md. Mahede hasan
Md. Mahede hasan

Reputation: 173

One possible solution to this issue is to run the sfc /scannow command in the Command Prompt with administrative privileges. The SFC (System File Checker) command checks for corrupted system files and repairs them if necessary. Here's how to do it:

  • Open the Command Prompt as an administrator. To do this, right-click on the Start menu and select Command Prompt (Admin)

  • Type the following command and press Enter: sfc /scannow

  • Wait for the scan to complete, which can take some time. If any corrupted files are found, the SFC command will automatically repair them.

  • Restart your computer and try installing NVM again. Note that this solution may not work for everyone, as the underlying cause of the error can vary. If the problem persists, there may be other steps that you can take, such as checking your antivirus software settings or performing a clean boot of your system.

I hope this helps! Let me know if you have any questions.

Upvotes: 1

Bamzerocks
Bamzerocks

Reputation: 177

My problem occurs on, particularly, Visual Studio Code.

The solution for my case is to run Visual Studio Code as an Administrator.

To run Visual Studio Code as an Administrator on Windows 11, search for Visual Studio from the Windows search bar, then right-click on the app of Visual Studio Code and select "Run as administrator".

Visual Studio Code, Windows 11 search

Upvotes: 17

Neisser Villa
Neisser Villa

Reputation: 11

Im on Windows 11. I had the same issue and it worked for me to open the console as an administrator, and then run the nvm use lts command.

Upvotes: 0

mxro
mxro

Reputation: 6878

I encountered the same issue and solved it as follows:

  1. Uninstall "NVM for Windows 1.1.7"
  2. Run the installer nvm-setup.exe as Administrator
  3. Open an elevated Command Prompt (with Administrator privileges) and run
  • nvm install 8.12.0
  • nvm use 8.12.0

Now running node -v in a non-elevated Command Prompt works without issue.

Upvotes: 201

mahdiyeh
mahdiyeh

Reputation: 11

If you have Node.js installed already, you need to uninstall it so it doesn’t lead to errors when using different versions of Node and installing packages from the NPM registry.

  1. If you have Node.js installed already, uninstall it
  2. Install nvm-setup.exe as Administrator
  3. open cmd.exe as Administrator
  4. nvm install node-version-number
  5. nvm use node-version-number

and finally, this article helped me much

Upvotes: 0

PatricNox
PatricNox

Reputation: 3918

Having nvm and want to use it in VSCode but getting those permission errors?

  1. Settings -> Update & Security -> For Developers -> Activate Developer Mode

  2. re-install nvm into C:\nvm & C:\nodejs

  3. Add to path, Search -> edit the system environment variables -> environment variables -> path -> add -> C:\nvm. Repeat for C:\nodejs

  4. restart vscode, now your integrated terminals has the nvm path & will always have access to them.

Upvotes: 0

VibingCreator
VibingCreator

Reputation: 97

"Elevation" refers "Windows Access Rights" by which Windows controls what you can do on the file, specifically what folders you can read and write to. You get them by using "Run As Administrator".

Enable Developer Mode

Settings -> Update & Security -> For Developers -> Activate Developer Mode

At this point, you will be able to use nvm without elevation.

Elevate nvm executable on demand

nvm root directory -> nvm.exe properties -> compatibility -> run this program as administrator -> apply

Whenever you need to use nvm, you will be prompted to grant elevation.

Run elevated command prompt

Press Windows + R, type cmd into the box and then press Ctrl + Shift + Enter.

Side note

I am not sure about this but I think you can use nvm 1.1.6 release without all that hassle.

Upvotes: 6

Juliancio
Juliancio

Reputation: 181

  1. Execute terminal as admin
  2. Access the folder from terminal
  3. Use the same command for nvm, ex.: nvm use 14.19.1

Upvotes: 18

Tosh
Tosh

Reputation: 130

none of the admin cmd run-s described above solved access denied issue. However I reinstalled nvm in a C:\NVM\nvm and made the nodejs folder to be C:\NVM\nodejs and it worked without any access elevation.

thanks @Daniel McMullen for the link to Wiki

Upvotes: 4

Takesha  Kaluarachchi
Takesha Kaluarachchi

Reputation: 439

Run command prompt in administration

  1. install node version with nvm

    nvm install <node_version> (ex: nvm install 16.10.0)

  2. use installed node version

    nvm use <node_version> (example:- nvm use 16.10.0)

  3. check node version

    nvm list <node_version>


Or uninstall the previous nvm version and reinstall and do upper steps

Upvotes: 0

Dony
Dony

Reputation: 1979

[2022 UPDATE]

I came across this problem multiple times. Trying to run it as administrator, but then get an Error 145, or struggling because my integrated terminal in VSCode is not running as administrator by default...

Here is an Easy fix, recommanded by the NVM Windows team in the Common Issues Page.

1- Create a folder at the root of your disk called "nvm4w" : C:/nvm4w

2- Go back to your nvm-setup.exe and run it (if you lost it, then go back to the NVM-Windows Releases and download the latest nvm-setup.zip file.

3- Then, when the installer ask you to "Select the folder in wich Setup should create the sumlink", select that "nvm4w" folder you just created.

After this, everything will be fine, the administrator privileges are not required anymore.

Upvotes: 5

Ali Coskun
Ali Coskun

Reputation: 25

It could be proxy issue. You can set the proxy url that npm already uses.

This is how you can find npm proxy config:

npm config list

Then set the same url for nvm:

nvm proxy "url"

Upvotes: 0

ThiagoCSoares
ThiagoCSoares

Reputation: 1

*Be carefull with Dev mode on

-- About Access Denied -- In this case, try with you Git Bash. Search your Git Bash > Open File Location > Right Click > Open Properties > Compatibility and check Run as Adminsitrator. Open Git Bash anywhere, type: nvm install version nvm list nvm use yourversion (ex. 17.99.99)

-- About NVM -v -- The command is: nvm version

I hope this solve your problem and others.

Upvotes: 0

Andrew J Hanlon
Andrew J Hanlon

Reputation: 49

I just downgraded my version of nodejs by using the "nvm use..." command, since I found using nodejs v17 was causing my issue. When I set my (Windows 10) machine to use nodejs v16.14.0 the problem went away. To downgrade versions, I did the following, because there can also be difficulty doing that: https://github.com/coreybutler/nvm-windows/issues/674#issuecomment-1050369304

Upvotes: 0

Sagar M
Sagar M

Reputation: 1376

  1. Open command prompt
  2. Right click on command prompt item in toolbar
  3. then again right click on command prompt
  4. click on run as administrator
  5. then run nvm use VersionNumber enter image description here

Upvotes: 8

Alish Madhukar
Alish Madhukar

Reputation: 575

  1. -->Press window key + x.
  2. -->Windows PowerShell(Admin)
  3. -->Now use nvm normally, you won't get any error.

Upvotes: 22

Arjun Ghimire
Arjun Ghimire

Reputation: 243

i have run command as a administrator it works

run cmd as administrator

and then after enter

nvm use 8.12.0/or your version which you desired to use

then it will work

Upvotes: 4

Diogo Eichert
Diogo Eichert

Reputation: 499

Version 1.1.9 of NVM for Windows has an issue that causes this problem. The solution is to remove it and then install version 1.1.7 (without Administrator privileges) and then it should work just fine.

Upvotes: 2

KCK
KCK

Reputation: 2033

Didn't find solution to my problem here, hence posting answer to this old question to benefit others.

I had installed node outside nvm without admin priviledges. In that case, no matter if you install or run nvm using admin priviledges, nvm use ____ will give access denied.

I uninstalled node manually, installed it from within nvm and then ran nvm use and it worked.

Upvotes: 0

localghost1234
localghost1234

Reputation: 9

I had installed the node version I wanted, but couldn't set it with nvm use [version] in Powershell. This worked for me:

  1. Download scoop and install sudo for Windows with it, using the instructions of the following link.
  2. Run sudo nvm use [version].

Upvotes: 0

Daniel McMullen
Daniel McMullen

Reputation: 346

I know this is a relatively old post and I believe most people landing here are trying to solve the access denied feature introduced with nvm 1.1.8 - I hope this is helpful to those folks.

This is covered in the repos wiki here

If you have access to enable developer mode on your machine - docs

You can enable developer mode and then when installing nvm for windows choose an install directory outside of the protected "Program Files" folder for nvm and nodejs.

I went with c:\Programs\nvm and c:\Programs\nodejs respectively, but you could also use APP_DATA as the base for both, or as suggested in the wiki 'nvm4w'.

I'm now able to use the latest nvm and run 'nvm use x.x.x' inside of VS Code.

Upvotes: 27

Muhammad Umer Ali
Muhammad Umer Ali

Reputation: 86

I was getting same issue. I wanted to install nvm s I deleted node js folder in program files and then installed nvm but instead of command I installed node js from installer which cause this issue. To use nvm we must delete previous node js installed so I uninstalled node js and nvm from control panel and then followed the following steps:

  1. Installed nvm
  2. install node js using command 'nvm install v8.12.0'
  3. nvm use 8.12.0

Upvotes: 0

Malik Haseeb
Malik Haseeb

Reputation: 671

I uninstalled NodeJS and also nvm from the my computer. And then redownloaded the nvm and installed the NVM and then by using this command I installed the specific NodeJS version npm install 16.x.x.

Upvotes: 0

dev1037
dev1037

Reputation: 41

For those using nvm v1.1.8 in Windows, I tried to install nvm and open it in cmd as an administrator., it didn't help.

Try using nvm v1.1.7. It worked for me :)

https://github.com/coreybutler/nvm-windows/releases/download/1.1.7/nvm-setup.zip

Upvotes: 4

Shivam Kumar
Shivam Kumar

Reputation: 17

It Solve my issue in windows

  • Remove node completely.
  • Install NVM
  • Open CMD as administrator
  • Install node specific version
  • switch on that version(nvm use yourversion)

Upvotes: -2

RogerIAm
RogerIAm

Reputation: 111

For me, I didn't wanted to run cmd with administrator rights every time I needed to change node version so what I did was go to NVM installation folder on windows is located at C:\Users\<username>\appdata\Roaming\nvm and modified the Properties>Compatibility to Run as adminstrator and now when I run nvm on my not-running-as-administrator-cmd it will just prompt me to confirm if execute as administrator.

Upvotes: 10

PercyPham
PercyPham

Reputation: 1638

Not like the other comments, you don't have to run the installer nvm-setup.exe as Administrator. Just install it like a normal software.

Make sure that when you run nvm use xxx, you run it in Command Prompt with Administrator privilege.

Upvotes: 152

HelloWorld
HelloWorld

Reputation: 7286

  1. Install nvm-setup.exe as Administrator
  2. open cmd.exe as Administrator
  3. nvm install 14.17.6
  4. nvm use 14.17.6

Upvotes: 25

Related Questions