nvm: N/A: version "N/A -> N/A" is not yet installed - node.js

I have nvm setup to use the latest long term support version in ~/.nvm/alias/default, by setting it to lts/*.
When I try and have my shell initialize my nvm version (zsh), I get the following error:
N/A: version "N/A -> N/A" is not yet installed.
Why is this happening?

Error: N/A: version "N/A -> N/A" is not yet installed
I got this error after doing nvm use (switching to older Node version 8.11.1, shown in .nvmrc file), nvm uninstall (newer Node version 9.0.0), then a git push.
nvm ls shows my "default" Node version was pointing to the uninstalled one: default -> 9.0.0 (-> N/A). This caused the error.
To fix: nvm alias default node points "default" to the latest installed Node version (8.11.1).
Now nvm ls shows default -> node (-> v8.11.1).

Turns out this error is telling me that I don't have it installed (ie the latest long term support version). To fix it, I had to run:
$ nvm install 'lts/*'
and it worked after that! Snagged from here

Your "default" Node version is not reachable (many reasons)
Many answers but there isn't a straightforward solution, let's try with:
nvm install 'lts/*'
nvm alias default node
the first command ensure you have latest LTS version installed and then set the default.

I faced the same issue when i used nvm to install node 12 and node 10. To fix this i used the command:
nvm alias default node

Prevent nvm from trying to use when first loading
You may not need (or want) the latest version of node installed, and yet wish to have the nvm command available, so in your .bashrc (or equivalent) include the --no-use flag when loading nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use # This loads nvm
Thanks to Ioannis Poulakas

I fixed it by running nvm use v12.21.0

Related

NVM ls command not picking existing Node version

I have already installed Node specific version in my system.
Now i have installed NVM using below command.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
if I run nvm in terminal , its showing all NVM options user can try. ( NVM installation is Successful)
My doubt is it not taking up already installed node version on nvm ls
PFA
nvm ls
> -> system
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
Please let me know how NVM can detect already installed node version.
If i install other node version with NVM , i may loose track of already installed node version as its not coming up in nvm ls
When I installed nvm recently I had to also do this step: nvm install node to install the latest version. Then you can check the following: node -v
If you do nvm ls remote it will display all available versions, then you can install any of them and view which ones you picked using nvm ls.
I set my node version default like this: nvm alias default <version>
I just ran into this issue as well using nvm. I did have to delete the package-lock.json file in the project directory and rebuild. But after doing so it seems to not have any trouble going between the node versions.
I just noticed you asked the question 4 months ago! I hope you were able to resolve the issue!

NVM doesn't update Node to the newest version

I'm using NVM (Node version manager) version 1.1.7 on Windows 10 to update Node through the Powershell terminal on VSCode. Today it occured to me that even though after updating and using nvm use 14.15.4 and getting 2 elevation dialogs and NVM telling me that it's now using the newest version, when I do nvm list or node -v or get-command node they're all still telling me that it uses an older version of Node.
After looking around for a bit some solutions said to add "runtimeExecutable": "/Users/*user*/.nvm/versions/node/*version*/bin/node" to the launch.json of VSCode, but that specific path doesn't even exist on my computer.
Check if nvm alias default <version> solves the problem

Node version not updating after "nvm use" on mac

I am trying to update my local node version from 8.9.0 to 8.10.0 using nvm. But it's not getting reflected. Here's what I tried:
node -v
-> v8.9.0
nvm use 8.10.0
-> Now using node v8.10.0 (npm v5.5.1)
node -v
-> v8.9.0
I am unable to get why it won't change. Please let me know what have I done wrong.
Adding few notes about my experience on debugging this problem.
First, I started out with the command provided by Jonathan which -a node and got the same output as op:
/usr/local/bin/node
/Users/<my-user>/.nvm/versions/node/v8.10.0/bin/node
Moving on to the next comment by Jonathan: Have you installed Node via Homebrew as well?, I tried uninstalling node by brew uninstall node and got and error that said it could not uninstall node as there was another program dependent on it. yarn.
And then realised that brew had installed its own version of node because I installed yarn through brew, which was overwriting the node version that I wanted to use through nvm.
Uninstalling brew's version of yarn+node fixed my problem.
I still needed yarn, and now I have to install yarn globally for each node version managed by nvm.
Inconvenient, I agree. But so is maintaining twenty thousand versions of node for each project so not very different in my opinion.
All of this was done on M1 MacOS and your output might vary based on your system.
Please ensure that when you input arch on command prompt, then output is i386.
This is achieved using Rosetta.
Following sequence of commands on terminal worked: -
nvm install 8.10.0
nvm install --lts
nvm ls
brew upgrade
arch -arm64 brew install n
n
Now select node version 8.10.0 using up or down arrow keys in keyboard and then quit from command prompt using command+q
Please do not try brew uninstall --ignore-dependencies node
Just check you environment variables first. It might be mapping to node#8.9.0.
You need to remove the environment variable first.
If you are also using volta. Volta may take precedence.
Use which -a node to verify.
If that is the case, use volta pin node#version to switch.
First check your nvm version installed on your local system. go to command prompt and type "nvm list" If you don't see the versions 8.10.0 in the list then install using command : "nvm install 8.10.0" and then try "nvm use 8.10.0".
For reference : http://www.tutorial-points.com/2018/11/nvm-installation-on-windows.html

understanding the output of `nvm ls`. Is everything installed properly?

I think I may have done something untoward during the install process of nodejs and nvm.
When I start bash or open a terminal I get:
:~$ bash
N/A: version "N/A -> N/A" is not yet installed.
You need to run "nvm install N/A" to install it before using it.
Using nvm ls from the command line I get:
going through my history I did find two lines where I'd tried to set an alias (I do believe I got that from a set of instructions I was following)
As far as I know, I'm not having any errors, other than when bash starts up, and those lines are generated from .bashrc:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
My primary aim here is to understand the output of nvm ls and is there anything there that needs to be fixed.
A bonus aside is, how do I get rid of these errors on logging in (other than simply deleting the last two lines) ;)
I'm on ubuntu 17.04
Update:
After checking the link in Matt's answer I see that these are the instructions I saw. It appears I missed a little here and there. This is what I have done and the results so far:
After checking out the link and runnin the update not much had changed except the lts/boron version number. Being yellow, I'm guessing it's not installed anyway. Still not sure why it's in my list then.
within the instructions I found I missed this one:
nvm install iojs-v1.0.3
So then I tried:
So I've cleared the red node -> stable and the iojs -> N/A lines. They're now a nice green. I realised the first default line was an alias.
I set the alias correctly:
Doing all these extra steps has finally got rid of my login errors, so that's a plus.
So I still have the yellow lts entries...
I'd still like to know should they be there, have I done something to make them appear, should they be installed? Is there a problem not having them installed?
The funny thing about how it has been setup; I have been running node and electron apps without any issue what so ever! Just adding to my confusion.
nvm is simply showing the default aliases, even though there are not versions installed for all those aliases.
By default, nvm doesn't install any Node versions, but it comes with the following aliases:
node and stable point to the latest version of Node.js.
iojs points to the latest version of io.js, an old unmaintained fork of Node.js.
lts/aragon points to the latest version of the Node LTS Aragon line (which is Node 4)
lts/boron points to the latest version of the Node LTS Boron line (which is Node 6)
lts/* points to the latest LTS release of Node.js, which is the same as lts/boron as of Aug 2017. (This will change when Node 8 moves into LTS)
Since you don't have any Node versions installed, it shows that those aliases don't point to any currently installed Node version, hence the N/A.
If you just want to run the latest version of Node.js, just run nvm install node.
Don't bother installing iojs or older versions of Node.js unless you need them. Just ignore the N/A output, nvm is just reminding you that these aliases do exist.
Have you tried
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
This is the installer script for NVM as documented on GitHub. When I visited npm they directed me to this page with instructions:
NVM github
The documentation also mentions that you need to choose the shell and open it again after installation. This maybe with a try.
nvm ls should lost the versions of node packages installed
Listing versions
If you want to see what versions are installed:
nvm ls

How can I use nvm to manage multiple locally installed node.js?

I already have multiple node.js versions installed locally in my x-Linux box,
0.10.40, 0.12.7 and 4.0
My default profile is pointing to node.js 0.12.7
Currently, I set my PATH to point to different versions of node when I start a new terminal.
I would like to use node version manager to use and manage different version of node that is already installed in my environment .
How should I do it without reinstalling node again?
Answering Original Post
For the small amount of data that you'd save by doing the following, it's almost not worth it. That being said...
Find where current versions are stored in nvm:
> nvm which
# mac
/Users/[username]/.nvm/versions/node/[version]/bin/node
# linux
/home/[username]/.nvm/versions/node/[version]/bin/node
Find all your non-nvm installed versions of node:
> which -a node
(..pending how you are running each of your terminals for each version of node installed will tell how effective this command will be).
Then symbolic link each of them to a folder matching the version.
> ln -s /path/to/node/version ~/.nvm/versions/node/[version]
# `$HOME` or `~/` or `/Home/username/` ... you know which works.
Node and Version Swapping Made Simple
nvm-controlled versions of node installed
> nvm ls
v0.10.33
v0.10.36
v0.10.40
v4.0.0
v4.2.2
v5.0.0
-> v5.1.1
system
default -> v5.1.1
system -> v5.1.1
node -> stable (-> v5.1.1) (default)
stable -> 5.1 (-> v5.1.1) (default)
iojs -> N/A (default)
Install version x, x.y, or x.y.z: nvm install x.y.z.
ie:
> nvm install 4.2.2
# If you want all modules from another version too:
> nvm install 4.2.2 --reinstall-packages-from=0.10.40
Set the default version used:
> nvm use 5.1.1
# But if only a local node command required, use:
# nvm exec [version] [command]
> nvm exec 0.10.33 node server.js
.nvmrc file in project root to define which local version of node to use.
#.nvmrc file contents:
5.1.1
You can't using installed nodejs version with nvm,
Because nvm use own directory for managing versions
You just need reinstall node versions
nvm install 0.12.7
And then
nvm use 0.12.7

Resources