nvm alias command not working on Windows 10 - nvm

As the title says, I'm on Windows 10 and I'm using the latest 1.1.9 nvm version.
I keep two node versions, one for work and one for my personal use.
I want to set aliases for them but the command doesn't work.
When I type
nvm alias work 10.16.0 (I have the version installed)
I get listed the running version of nvm and the usage guide.
Then when I try
nvm use work
it says that "work" isn't a recognised version.

According to the GitHub Repository Issues, this version of nvm doesn't have a feature for Aliases.

Related

Vagrant Node Version Not Updating in VM

I am currently trying to do this:
https://github.com/workshopper/javascripting#run-the-workshop
When I type javascripting it gives me the error:
EEXIST: file already exists, mkdir '/home/vagrant/.config/workshopper'
From what I've found the EEXIST errors comes from the node version not being updated.
The terminal on my mac shows:
% node -v
v12.18.3
% npm -v
6.14.6
But the terminal inside my Vagrant VM shows:
% node -v
v8.9.4
% npm -v
5.6.0
I am assuming it is because /usr/local/bin is not in my $PATH but I'm not sure how to update that, or even if that is the problem. Been struggling with this for a while and haven't found anything online that fixes it.
How do I update node and npm inside the VM?
Thanks.
[Edit]
Just in the odd case someone has this problem in the future, here is how I managed to fix it.
Inside of the VM run:
nvm ls
check to make sure the default is the latest version (in my case it should have been v12.18.3). If it is not the latest, then use:
nvm alias default (latest version number)
If you don't restart your VM then it may not update the current version. In that case use:
nvm use (latest version number)
And then you should be good to go.
Hope this helps!
For me, it was because the node version on my computer was newer than the node version in vagrant. I updated node in vagrant and it worked.
nvm install <version>
nvm use <version>

nvm use does not switch node versions

on a Windows 10 machine and using nvm4w I tried:
from the above image:
node --version to check the current version
nvm list to list installed versions
nvm use 8.8.1 so we switch from 6 to 8
nvm on to enable it
node --version to re-check the node version
what am I doing wrong?
I had to delete the folder located at C:\Program Files\nodejs:
And then run nvm use {version} again to repopulate this folder with the correct node version.
I suspect that nvm is having trouble deleting this folder due to permission issues.
So I found a workaround.
I renamed C:\Program Files\nodejs to C:\Program Files\nodejsx
and then running nvm use versionNumber works fine.
Seems like nvm cannot change it to a symlink and fails silently.
I was also facing the same issue.
I had node version 14.15.1 installed in my machine and had to use 12.16.1
I'm using Windows 10.
After installing 12.16.1 via nvm it was showing only this version in nvm list and it wasn't showing current version in use.
Even after node use 12.16.1 the node -v was still showing 14.15.1.
Steps to resolve this issue:
Uninstall Nodejs from control panel.
Install Nodejs 12.16.1 using nvm install 12.16.1
Install Nodejs 14.15.1 using nvm install 14.15.1 (or the version which got uninstalled)
Switch version using nvm use 12.16.1 (change the version number accordingly)
Result:
C:\>nvm list
14.15.1
* 12.16.1 (Currently using 64-bit executable)
12.3.1
C:\>node -v
v12.16.1
nvm works based on the fundamental idea of symlinks. When a user is trying to hit the command nvm install <node_version> the entered version of node is getting installed even if you have changed the C:\Program Files\nodejs to C:\Program Files\nodejsx.
If nvm fails to create the new folder C:\Program Files\nodejs it will fail silently and you won't be informed.
You must manually check for the existence of the path C:\Program Files\nodejs if it exits then delete the folder and change the node path in your environmental variables. This will help you to figure out the version of the npm command.
Your problem can be solved by reinstalling the nvm version with Administrator privileges or just by renaming the folder C:\Program Files\nodejs
You can find further information here: https://github.com/coreybutler/nvm-windows/issues/67
This happens to be the issue till date and deleting nodejs folder does not work.
Just run nvm install using cmd as administrator.
So even if you have downloaded nodejs from cmd without admin privilages, uninstall it and install again using cmd as admin.
This is what worked for me after trying almost every solution from github and stackoverflow.
For me the problem (on Linux) was that I had installed node with Homebrew, and it was preventing the use of nvm. Before nvm could set up the correct symlink, I had to
brew uninstall node
I first found out about this situation by running
which node
This told me that node was being symlinked from Homebrew at
/home/linuxbrew/.linuxbrew/bin/node
instead of, as we want, from nvm at
/home/john/.nvm/versions...
As soon as "which node" reported that it was using the node from nvm, things were resolved for me.
1) Install NVM from the link : https://github.com/coreybutler/nvm-windows/releases.
2) Copy the settings.txt from the "C:\Users\YOUR_USERNAME\AppData\Roaming\nvm". to "C:\Users\ YOUR_USERNAME"
3) Restart your system for the changes to reflect.
4) Open the console and type below command :
nvm list
5) To install the 6.9.3 version run the below command :
nvm install 6.9.3
6) After the installation is complete it will add the node version in the nvm. To check the same type command :
nvm list
7) To switch the command version type command below command :
nvm use 6.9.3
To verify the node version switch type the command “node –v”
8) Its will display the node version in use.
For more details please check the below link :
https://www.tutespace.com/2018/11/nvm-installation-on-windows.html
Let us know if you still face the same issue.
I had the same problem.
My solution is that i uninstalled nodejs via chocolatey (the way i installed it) and then nvm worked again.
After checking the nodejs folder in C:/Program Files i noticed that nvm probably works via creating a link/shortcut to the nvm folder where the different versions of nodejs are stored. That´s the way the "Path" and everything works.
I hope that helped.
I have tried to switch Node version using nvm but it is not reflecting so I deleted the folder inside c:/program files/nodejs
after deleting the folder follow the same steps to switch the npm version using nvm and it will switch the node version.
The steps I had to follow were:
Uninstall node if there was an installation outside of nvm
Ensure "C:\Program Files\nodejs" was deleted before installing nvm
Install nvm which still fails to install node but from the errors it seems that's because its ultimately pointing at urls that have been decomissioned
Use "nvm install NODE_VERSION" to install at least 2 versions of node which again fail as in 3)
Download the versions of node I tried to install and unzip the entire contents to their respective %appdata%/nvm/vNode_version folders
Use "nvm use NODE_VERSION" to switch between either version I've installed [but be careful... "npm -v" did not work until in visual studio until I closed and re-opened the program]
If anyone knows how to point nvm to the up to date urls, it'd be great to know. I suspect everything would work fine when running nvm from powershell run as administrator
Follow this step
1.delete node and npm in path
To Find Path
which node
output
/c/Users/balaji/AppData/Roaming/npm/node
which npm
output
/c/program files/node.js
2.To list out version
nvm list
3.set node
nvm use version
To know remote version
nvm list available
To know local version
nvm list
Yet another answer because none of the others helped me.
Setup
Windows 11
Multiple accounts
Non-default install and symlink directories
I installed nvm using different directories than the default because this is necessary to avoid:
Issues due to spaces in the path
Issues when using nvm on two different accounts on the same machine
Solution
This solution works for any number of accounts on the same machine.
Uninstall any nvm and nodejs you have.
Make sure no directory from them remains (in Program Files, Program Files (x86) and any other place you might have tried installing nvm/nodejs)
Reinstall nvm with:
An installation path that contains no spaces, and is not in any specific user's directory (e.g. C:\nvm)
A symlink path that contains no spaces, is not in any specific user's directory, and is not under nvm's directory (e.g. C:\nodejs)
Open your shell as administrator, install your desired node version(s) (e.g. nvm install lts) and activate one (e.g. nvm use 18)
Test that the version was activated correctly with nvm current and node --version
Every time you change your node version with nvm use or install a new one with nvm install, do it in an administrator shell
None of the above helped in my case.
I could see the symlink was created and correct but NVM4W would still not "use" the correct version.
The node version I had installed with NVM was not compatible with my version of Windows.
When you run "nvm ls" or "nvm current", it calls GetCurrentVersion() which runs "node -v" in the command line. If that output is anything other than the current version, such as the warning that you are running an incompatible OS, it will fail to indicate the currently selected version. It does so in a way that is not obvious why "nvm use x" did not work.
You can bypass the node OS check with an environment variable (node version >=14 as far as I could find):
How to set the NODE_SKIP_PLATFORM_CHECK environment variable to 1 which skips the version check
Though you may need to update Windows or use an earlier version of node if node doesn't function as expected.
With that set, "nvm use" functioned as expected.
I met this problem this morning. And I think the reason for the problem is that it's different between the nvm's settings and env configuration. I solved it the following way.
open the path of nvm installation.
open the setting.txt file and have a check with the path value.
open the environment variables Control panel in Windows.
check if it's the same between the value of NVM_SYMLINK in the system path and path in the setting.txt
change two configuration to same values.
Mine was caused by EMSDK. which I set on my .zshrc to load it automatically. removed the emsdk related lines, and the node was following nvm.
On Windows uninstalling Node.js at Control Panel > Programs > Uninstall a program, and letting nvm install the desired node versions also solves this issue.
In my case the things didn't work as described inside CI/CD service (TeamCity to be exact). I spent half a day, trying to find a solution and tried everything mentioned here and other similar questions. So, what worked:
Perform a clean install of nvm (removing older standalone versions of nodejs fist), as specified by multiple other answers. Install node versions only using nvm.
Make sure that process that is running your "nvm use" command has "Full Control" privilege to the root of nvm installation. So that it could delete the symbolic link "nodejs" folder when switching versions.
Change a policy on your server to allow that same account creating symbolic links:
This point was, somehow, not mentioned by anyone anywhere, so it took me very long time to figure this out.

Use NVM To Install Latest NodeJS For Specific Major Version

I want to install the latest minor/patch version of NodeJS 4 using nvm. I don't just want "latest", because that would be NodeJS 8 or whatever later, potentially breaking-change version is out now.
If it were an npm dependency, I would be able to say nvm install "^4", but that doesn't work. Is there a simple command to do this? If there isn't, is there something I can do on the command line to find the latest version and install it in a one-liner that works on both Windows and Unix-based consoles?
(nvm maintainer here)
If you run nvm --help (make sure you're using the latest version of nvm), you'll see a description of all the things nvm supports. Specifically, nvm does not support semver ranges, however, nvm install 4 or nvm install 4.x will install the latest available version of node 4.
Separately, you can use nvm install --lts=argon (and nvm alias default lts/argon if you want to peg to the LTS line specifically instead of just v4.

How do I uninstall NodeSource NSolid from my computer?

I installed NodeSource's NSolid on my computer and it took over my node binary. How do I uninstall it?
NSolid provide an uninstall script. On a Mac, simply run:
sudo /usr/local/nsolid/uninstall
N|Solid replace node binary to ensure that all your apps are getting the additional features of N|Solid. The best way to return to Node.js again is reinstalling it.
N|Solid is shipped with a specific npm version that guarantee total harmony on the ecosystem. Reinstalling Node.js also replace the npm version avoiding issues about version miss matching.
Also you should remove manually the nsolid binary. You can get the installed path running which nsolid

Postgresql via homebrew vs. mountain lion OS X

This is bothering me to no end.
I'm setting up a Rails 3.2 environment with Postgresql on my Mac with OS 10.8.2 (Mountain Lion).
I basically followed the directions in the Railscast, and installed postgresql version 9.2.0 via Homebrew. but whenever I do
which psql
and
psql --version
it always shows me the location and version of the system postgresql that came preinstalled with Mountain Lion (/usr/bin/psql and version 9.1.4, respectively), rather than the location and version of the Postgresql that I installed with Homebrew (/usr/local/bin and version 9.2.0, respectively).
I also set up a Launch Agent, so that postgresql automatically starts up when I start the system.
I've even tried following the directions from this blog, and I still get the same results when I run which psql.
However, when I do:
ps -ef | grep postgres
I receive the following results:
501 556 120 0 Fri02AM ?? 0:00.12 /usr/local/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log
Does this mean that I'm running the homebrew version of postgresql?
Do I have to uninstall the system postgresql?
Another option would be to use Heroku's Postgres.app, I personally find this a bit easier to setup and manage.
http://postgresapp.com/
by adding directory path (/usr/local/bin) to the config file, ~/.bash_profile you will get resolve the above issue.
to know more refer this link.
If you use Postgres.app from Heroku, by adding
export PATH=/Applications/Postgres.app/Contents/MacOS/bin:$PATH
to ~/.bash_profile, it should resolve the issue.
Try adding:
export PATH=/usr/local/bin:$PATH
in your ~/.bash_profile
I think this works for when you install Postgres via Homebrew