The clean way to uninstall would be first to uninstall all the node packages which you have installed, you can list all those packages using
nvm list
To uninstall a specific NodeJs package run
nvm uninstall v16.13.0
After you have uninstalled all the packages go to the directory
C:\Users\%USERNAME%\AppData\Roaming\nvm
there you will see unins***.exe you can perform a clean uninstall there.
This will only work if you are or have installed all the node versions using NVM (Node Version Manager)
Answer from Umer Kiani on Stack OverflowThe clean way to uninstall would be first to uninstall all the node packages which you have installed, you can list all those packages using
nvm list
To uninstall a specific NodeJs package run
nvm uninstall v16.13.0
After you have uninstalled all the packages go to the directory
C:\Users\%USERNAME%\AppData\Roaming\nvm
there you will see unins***.exe you can perform a clean uninstall there.
This will only work if you are or have installed all the node versions using NVM (Node Version Manager)
In your terminal, just type the code below
nvm root
This will show the root path of nvm on your computer.In the folder you can find a unins.exe file. Run it. That's all.
Do I have to uninstall the old one then install the newer version if I only want to keep the latest version?
I'm going to assume a few things here:
I had a similar issue to this (using Windows 11).
The main issue lies in that PowerShell profiles are not created automatically upon installation (for some reason). The profile path needs to exist for the fnm script (containing fnm environment variables) to run--as mentioned in the fnm GitHub page
Steps:
Here is how to set up the PowerShell profile:
First, check that your profile does not exist. in PowerShell, run:
notepad $profile.If Notepad cannot find the path, continue below, otherwise, jump to step 3.
Open PowerShell using admin access and paste the code:
ps:> if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }This basically create the profile path. (script from Microsoft).
Restart PowerShell.
Now we're going to make sure PowerShell is able to run scripts. Open it and run:
ps:> Get-ExecutionPolicy # If it says Restricted, then it won't run node, or it's associated env variables.To change it, open PowerShell in admin access, and use this code to change the restriction for PowerShell execution policies:
ps:> Set-ExecutionPolicy -ExecutionPolicy Unrestricted
# Accept the change and restart PowerShell again.
This is my preferred option, since I have not experimented with the other options--found in the link in this bullet point.
- Now, you should be able to open the Profile path by running:
ps:> notepad $PROFILE
# append the script from the `fnm` documentation into the file
ps:> fnm env --use-on-cd | Out-String | Invoke-Expression
- Now you should be able to just type
node --versionand it should work with no issue.
Copy the command:
fnm env --use-on-cd | Out-String | Invoke-Expression
Into $profile to save the settings.
Run below command in PowerShell before installing NodeJs -
fnm env --use-on-cd | Out-String | Invoke-Expression
I was getting the same error, was able to install node after I ran it.
Image
I faced the same error , if you use linux you can just add the command
fnm env --use-on-cd | Out-String | Invoke-Expression to your profile of shell.
Otherwise , just run it in shell and fnm list then you can choose from the installed ones.