"nvm use 16.13.0" will return this error "exit status 145: The directory is not empty."
Asked Answered
S

7

35

I have 2 versions of node.js , as follow:-

Your environment has been set up for using Node.js 17.1.0 (x64) and npm.

C:\Windows\System32>nvm list

    16.13.0
    8.16.2

but when i try to use the first version i got this error:-

C:\Windows\System32>nvm use 8.16.2
node v8.16.2 (64-bit) is not installed.

and when i try to use the second version i got this:-

C:\Windows\System32>nvm use 16.13.0
exit status 145: The directory is not empty.

so what is going on? thanks

Selestina answered 12/11, 2021 at 21:42 Comment(0)
F
113

if it is a Windows machine go to C:\Program Files\nodejs. Then rename that folder to C:\Program Files\nodejsx. After that please check "nvm use v.v.v."

Foreknow answered 5/3, 2022 at 5:42 Comment(5)
Thank you so much It worked for me, I was scuffing for the versions of node.js from all 2days but not gonna any conclusion at EOD. bcz from the starting I was working on Linux, for the first time I had to work with windows os. It Helped me a loot a small thing changed my Hard Work to smart worked, Thank you so much once again.Ulani
how is it working? And can you tell why am I requiring usage of admin cmd instead of running cmd normallyDecrescendo
why does this work...Revelationist
This should be the selected answer.Noddle
The reason this fails is likely due to the fact that nodejs already exists on your System, but not in a manner that was installed by nvm. Renaming the nodejs folder to nodejsx (or any other folder, or deleting it entirely) will free up the path needed for nvm to manage your version, resolving the fault. This is why uninstalling nodejs also works, as per other answers in this thread.Earlearla
R
30

I just fixed it by uninstalling Node.js from the Settings -> Apps menu. According to the https://github.com/coreybutler/nvm-windows/pull/615 pull request, nvm cannot change the version because it's conflicting with the normally installed Node.js version. Try deleting Node.js from the Apps settings menu.

Rapp answered 15/11, 2021 at 11:56 Comment(2)
Worked, but it is quite strange, as I used to "nvm use" even with node.js installed.Inerasable
In my case the problem was that I was switching the node version whilst I had an open terminal running ng serve. Closing the process solves the problem for me.Canescent
A
16

When this happen:

C:\Windows\System32>nvm use 16.13.0
exit status 145: The directory is not empty.

Just make sure, the nodejs folder is empty, check C:\Program Files\nodejs or C:\Program Files (x86)\nodejs, otherwise delete the content. Then try again nvm use XXXX (xxxx is the version)

Amish answered 13/2, 2022 at 2:33 Comment(0)
P
2

On windows 10, It fixed after I uninstalled my node.js application from control panel. And install specific version with nvm install x.x.x then nvm use x.x.x using Powershell in administration mode.

Pyramidon answered 22/6, 2022 at 19:55 Comment(0)
F
1

I meet same issue. I have resolved as:

Make sure you delete all old nodejs.

step 1:uninstall nodejs and remove node_home and npm_home;

step 2: download nvm and Install it. My OS is win, so link is : https://github.com/coreybutler/nvm-windows/releases. if your OS is MAC or Linux, you can use brew or apt install utils to install.

step3: open cmd.exe, run it as "administrator", checking NVM_HOME and NVM_SYMLINK example:

NVM_HOME=D:\dev\node\nvm
NVM_SYMLINK=D:\dev\node\nodejs

Note:make sure nvm home and nvm symlink need in diff forlder.

if not set , your must set manual and add path:

%NVM_HOME%
%NVM_SYMLINK%

open a new cmd.exe terminal, and make sure these is OK.

step 4: Open new terminal prompt:

run 'nvm on'
run 'nvm list'
run 'nvm install 14'
run 'nvm use 14.18.2'
run 'node --version'

enter image description here enjoy it.

Fizzy answered 16/12, 2021 at 7:6 Comment(0)
H
1

suggest you uninstall local nodejs from control panel and try again nvm use *******

Hypochlorite answered 15/8, 2022 at 12:49 Comment(1)
This is not an answer. Consider givin feedbacks using comments not New answer. This way we keep answers reliable.Gidgetgie
D
0

The problem is that nvm cannot update the "junction" folder (symlink), which is in your case pointing to "program files", if executed from a non-admin prompt (case 1). Or the junction folder was overwritten by "real" nodejs, and cannot be used as such anymore, which probably means that you installed nodejs after nvm (case 2). The junction folder is defined by the NVM_SYMLINK environment variable.

Please note that this was improved a bit in the later releases of NVM, now the messages should be cleaner, and also NVM should be now smart enough to rise an admin elevation prompt automatically if it is necessary to update the junction folder (i.e. if user's junction is pointing to something inside "program files" but he tries to update it from a non-admin prompt).

Dedication answered 11/2, 2023 at 11:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.