-1

I don't know which node version managers there are, but it's not installed with apt, and nvm. I'm using Debian based pop_os. If there's a way to tell where nodejs is installed then that would be super, as I imagine that would indicate node version manager is used.

janat08
  • 1,725
  • 2
  • 16
  • 27
  • 1
    Version mangers or node itself? You ask about each at different points but they aren't the same thing. – VLAZ May 09 '22 at 15:26
  • 1
    `which node` indicates what `node` is runs. The result may or may not indicate which, if any, Node version manager is installed. "Where" it's installed depends on how it was installed. – Dave Newton May 09 '22 at 15:27
  • 1
    In addition to what @DaveNewton said, there is the `alternatives` which might be used as a "version manager". It is used to switch between different versions of some executable, thus it might be changing between different Node installations. – VLAZ May 09 '22 at 15:31
  • What I meant is in liu of iterating every manager I might have used, letting me determine by that by looking at clues in installation directory. – janat08 May 10 '22 at 10:04
  • There must be a command for instead of invoking node, telling from where it's included in path. – janat08 May 10 '22 at 10:08
  • If I install nvm will it just overwrite last installation as it will be listed last in path? – janat08 May 10 '22 at 10:09

1 Answers1

1

npm is the package manager for the Node JavaScript platform in Ubuntu-based operating systems. It puts modules in place so that node can find them, and manages dependency conflicts intelligently. It is extremely configurable to support a wide variety of use cases. Most commonly, it is used to publish, discover, install, and develop node programs.

Install also node-opener to have full npm features enabled.

sudo apt update
sudo apt install npm node-opener

To find out where node.js is installed run the following command:

which nodejs && which node

An up-to-date version of npm will installed as part of the node snap. npm should be run outside of the node repl, in your normal shell. After installing the node snap run the following command to enable npm update checking:

sudo chown -R $USER:$(id -gn $USER) /home/your-username/.config

Replace your-username in the above command with your own username.

node snap package users can switch between versions of Node.js at any time without needing to involve additional tools like nvm (Node Version Manager), for example:

sudo snap refresh node --channel=18/stable

snap packages exist within a sandboxed environment. To access the installed node snap, run snap run node. To get the version of the installed node snap run snap run node -v For example if you installed node by running sudo snap install node --classic the results of running snap run node -v would be v16.15.0 which is currently the default stable version.

karel
  • 5,489
  • 46
  • 45
  • 50
  • I'm trying to change node version and I can't tell how to reinstall it because I forget how it was installed. – janat08 May 10 '22 at 10:06
  • The current default stable version of the node snap package in Ubuntu is 16. You can install as many different versions of node as you want in Ubuntu, and select which version of node to use each time by following the instructions in [this answer](https://stackoverflow.com/a/49445862/). – karel May 10 '22 at 10:15
  • pop-os@pop-os:~$ which node /run/user/999/fnm_multishells/26574_1652205256417/bin/node – janat08 May 10 '22 at 20:09
  • pop-os@pop-os:~$ cd /run/user/999/fnm_multishells/26574_1652205256417/bin/node bash: cd: /run/user/999/fnm_multishells/26574_1652205256417/bin/node: Not a directory – janat08 May 10 '22 at 20:09
  • I just installed a new node without deleting the previous node, and I still get the old version -v command. I did using snap, without doing the npm related commands. – janat08 May 10 '22 at 20:10
  • snap packages exist within a sandboxed environment. To access the installed node snap, run `snap run node`. To get the version of the installed node snap run `snap run node -v`. – karel May 11 '22 at 00:24
  • Ok, and how do I make other apps use the snap node if its not in path? I think ill just go with nix now. Yep I installed node-opener, and the node in path is used instead. – janat08 May 11 '22 at 15:07
  • Jesus what do you know, I'm using FNM. Thanks for the which hint, that's like the gist of what I was looking for. It didn't occur to me to check what fnm_multishells is. – janat08 May 11 '22 at 15:31
  • Anyway the nix thing worked, except that npm -g installs require a short workaround, other than that you can use that as version manager for any tool/language. – janat08 May 11 '22 at 15:38