Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exit status 1: Access is denied #717

Closed
CASPERg267 opened this issue Jan 1, 2022 · 17 comments
Closed

exit status 1: Access is denied #717

CASPERg267 opened this issue Jan 1, 2022 · 17 comments

Comments

@CASPERg267
Copy link

Issue:
i get access is denied when i try to use specific version of node

How To Reproduce:
i installed 2 version node 14 and node 16
when trying to use node version 14 by typing nvm use 14.18.2 i get this error
same error happens when using v16

Expected Behavior:
It should use node version i choose to use

@CASPERg267
Copy link
Author

image

@CASPERg267 CASPERg267 reopened this Jan 1, 2022
@danilopolani
Copy link

@CASPERg267 try to open the CMD as administrator

@coreybutler
Copy link
Owner

@danilopolani is correct - see https://github.com/coreybutler/nvm-windows/wiki/Common-Issues#permissions-exit-1-exit-5-access-denied-exit-145

@patricknelson
Copy link

patricknelson commented Apr 26, 2022

Ideally this would be addressed with a UAC dialog for those of who have local admin privileges but are not able to enable a Developer mode (likely due to running on an older version of Win10 or due to being locked out because of group policy restrictions).

Would you be willing to add the option to configure nvm to enable this alternative approach?

@squidjam
Copy link

squidjam commented May 2, 2022

Even then, not everyone has administrative rights to the computer (some of us work with impossed restrictive policies) and as of testing it today with developer mode activated, this no longer works as intended (i.e. I have developer mode active, yet I get access denied when issuing an nvm use command).

@Sharparam
Copy link

Can confirm that even with developer mode enabled, the access denied error still happens. Windows 10, 20H2, build 19042.1645.

Can also confirm that I can create symbolic links manually from a non-administrator powershell session:
image

@terryjiang2020
Copy link

terryjiang2020 commented May 11, 2022

The second most common permission issue is trying to use a protected directory for storing Node installations. Windows requires administrative privileges to write to C:\Program Files. Many users want to install different versions of Node to this directory, but this forces NVM4W to create download (write) Node/npm to a protected directory. It's typically simpler to store Node installations in an alternative directory, such as C:\nvm4w.

Several people have complained about protected directories, and I'm sorry... but I'm not the person to talk to about that. Your best bet is to reach out to Microsoft, because it's an operating system requirement. Every program has to deal with this. Remember that NVM4W is basically an installer, so it needs installer-like permissions.

@coreybutler I found a solution for that as people can install both node and nvm in another disk (e.g. d:/) in order to avoid this. Perhaps consider adding this as a suggestion in your doc.

@coreybutler
Copy link
Owner

@terryjiang2020 has correctly cited that Windows protects some directories, even if you have developer mode enabled.

Per the suggestion, I've added the following change to the wiki:

image

@goleary
Copy link

goleary commented May 11, 2022

curious that this has only become an issue lately...what has changed?

@devniel
Copy link

devniel commented May 18, 2022

same issue here :(

@s100
Copy link

s100 commented May 24, 2022

@coreybutler To reduce the number of people having this confusing problem, it might be a good idea to modify NVM4W to check whether it has administrative permissions proactively at launch, and display a meaningful warning. Or even link to the relevant README. I've found that it's possible to get into some quite odd states because some NVM4W commands work without admin permissions but some do not.

@tominyorks
Copy link

@coreybutler - may I suggest another potential addition to the wiki?

I've struggled for a few hours with this access denied error, enabling developer mode, using different folders to store my node installations. I was able to run the nvm commands from a normal command prompt or PowerShell terminal, but still got the access denied error in VS Code.

I finally found the issue was caused by the repository I was working on was cloned into my user's documents folder. I closed VSCode, moved the whole folder structure out of my documents folder and into a new folder, re-opened VSCode and blam, everything worked perfectly.

@squidjam
Copy link

Please update the guide:

Checklist before installing nvm-windows

  • Developer mode on Windows: on
  • Uninstall all previous versions of nodejs and nvm.
  • Create the following folder structure:

-- c:\nvm4w
-- c:\nvm4w\nodejs
-- c:\nvm4w\nvm

  • Make them all write enabled (right click the folder, check properties, see that Read only is not marked at all)

Run the installer as an administrator.

  • When prompted, use your folders instead of the ones suggested by default in the installer.
  • Once finished, close any terminal, cmd or PowerShell window where you intend to use nvm, and
  • Open a new one.

Test everything is ok

  • Run nvm --version to check if it's installed correctly.
  • Run nvm root to verify that your settings have been applied correctly.

Run it

  • Run nvm install
  • When finished, run nvm use

@edgarbjorntvedt
Copy link

running npm use <version> in a cmd opened with administrator privileges solved it for me

@RichardBradley
Copy link

I couldn't get nvm-windows to work on my Windows 10 that's heavily locked down by my company's IT dept. I have local admin rights, but in a separate account. After running "nvm use " in an administrator prompt, I was unable to use the installed node from a non-admin prompt. Whenever I interacted with the symlink created, it just said access denied. When I looked at the symlink in explorer, it prompted me to grant myself access, but then that failed if I tried it.

I think admin rights are too restricted on my machine. I'm going to manually install multiple nodes and just switch my PATH each time.

I don't see why nvm needs to run as adminstrator anyway? I feel like it would be much more accessible to most users if it ran as a regular user.

You wrote in the docs that "Windows requires elevated administrative privileges to create symlinks", but that's not true.

On my Windows 10, I can create a symlink to a dir as a normal user with mklink /J link target. I'm pretty sure this has worked for several versions of windows, perhaps since they first added NTFS itself.

@Sharparam
Copy link

mklink /J

/J makes an NTFS junction, not symbolic link.

Also I think the admin rights are only for when you install into one of the "Program Files" folders, as those require special permissions. After I installed nvm to a regular folder it works just fine without admin privileges.

@coreybutler
Copy link
Owner

I'm locking this conversation because comments are starting to deviate from the subject. If you have suggestions or wish to discuss a feature, the discussions is the appropriate place to do it. I do not make a habit of reading through closed issues.

Repository owner locked as off-topic and limited conversation to collaborators Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests