How to know if node is installed with homebrew or nvm? - node.js

I had installed & uninstalled node on Mac OS with multiple ways using homebrew, nvm etc
Now I don't remember which technique I had used last time to install.
Is there a way to find our how node was installed or which tool is used to install node ?

Related

How to tell how node was installed?

I may need to reinstall some js libraries, starting with node.
I know node is installed since node -v returns v16.0.0. But I don't know what I used to install it (e.g. npm, homebrew, yarn etc).
How can I find this out?
Notes
which node
/usr/local/bin/node
brew list node
/usr/local/Cellar/node/16.0.0/bin/node
/usr/local/Cellar/node/16.0.0/etc/bash_completion.d/npm
/usr/local/Cellar/node/16.0.0/include/node/ (17 files)
/usr/local/Cellar/node/16.0.0/lib/dtrace/node.d
/usr/local/Cellar/node/16.0.0/libexec/bin/ (2 files)
/usr/local/Cellar/node/16.0.0/libexec/lib/ (2752 files)
/usr/local/Cellar/node/16.0.0/share/doc/ (2 files)
/usr/local/Cellar/node/16.0.0/share/man/man1/node.1
/usr/local/Cellar/node/16.0.0/share/systemtap/tapset/node.stp
npm list node
zsh: command not found: npm
which node will tell you where node is installed. This might help you figure it out if you know X installer installs at a specific installation.
npm list node and npm list -g node should rule out whether or not your installation comes from npm.
Similarly, brew list node will only list Node versions installed with homebrew. (Note that you might have node installed via homebrew at a certain location different than what which node returned, meaning you did many installations.)
As for n and nvm, if they're installed, I'd try changing node version from those utilities. If doing so changes the output of node -v, then node must be installed from those.
If you're running a UNIX-based operating system there is a history command that will show you the commands previously executed in the terminal as wrangler commented. If you're using Ubuntu you can find the log history for apt-get in /var/log/apt/history. These utilities (npm, homebrew, yarn, apt-get, etc.) all have logs that you can look through. If you're using Windows you probably downloaded node directly from their site.

How to install node package on MacBook for Socket.IO?

I have downloaded Node from Here for MacBook. Now when I double click on package, it is giving me error.
Anyone knows about this ?
Or can you give me other way to install node on MacBook ?
It used be fine. But then I haven’t tried to download directly from their site for a while.
Since I have a need to install multiple versions of node and switch between them, I used nodenv installed via Homebrew. Another popular tool people use is nvm.
You can follow simple instruction at https://brew.sh/ to install Homebrew and you can install node by brew install node. If you want to be able to switch between versions, you can install nodenv by following Homebrew install steps at https://github.com/nodenv/nodenv/blob/master/README.md. Then install node by nodenv install 12.16.1

NodeJS can't install it properly

I had problem with create-react-app and turned out I gotta update my version of nodeJS. The thing is that I can't do so. when I type node --version I get v11.10.0, however when I type sudo n stable, I get:installed : v10.16.3 (with npm 6.9.0).
However when checking version of node I all time get this 11.10.0. How can I get this last stable version 10.16.3?
EDIT: SOLVED
turned out nvm was installed on laptop and it controled node version
I would suggest you use nvm to manage your node versions. It allows you to download multiple versions and you can assign versions on a per project basis. It also allows you to choose which version you want as default
Install nvm it will allow you to install and use any version you want.
Installation steps on ubuntu 18.04

can't revert to older version of node, can't uninstall node, OSX

Have installed node 0.12.2, but need to revert to 0.10.33 to run the applications I need to.
I have tried installing 0.10.33 and switching versions using
set 0.10.33 to default with 'nvm alias default 0.10.33'
But node runs previous version (0.12.2) when started again.
I have tried uninstalling node via various methods, but each one has been blocked:
uninstall node
"You must be in root to run this tool"
(I am the only user (with Admin access) on my machine
I tried
cd /
then
uninstall node
But still got
"You must be in root to run this tool"
Tried
sudo uninstall node
"Uninstall Failed...
Reason: ErrorMissingBundle"
I may have installed node with Homebrew - it was a while back, can't quite remember. So tried:
brew uninstall node
"Error: No such keg: /usr/local/Cellar/node"
Other information I can give:
which node
/usr/local/bin/node
I see node and npm in
/usr/local/bin
Any help most appreciated - I'm not a command line expert, and fairly new at Node.
To switch from different node.js version with nvm just use nvm use 0.10.33
It looks like you might be using NVM (node version manager). If you are you can install different versions using
nvm install version_no
and then you can switch versions using the command
nvm use version_no
If you have not used NVM to install node you can uninstall node using the instructions in this answer - How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X).
Then if you need different versions of node I would recommend using NVM, which allows you to install and use different versions of node on the same system. https://github.com/creationix/nvm

How to backup my Node.js setup when upgrading

I want to upgrade Node.js on Ubuntu, but I want to make sure that if anything goes wrong I could revert back my source code, installed modules and node binary to the working setup. How to achieve that?
You can install any version of node.js just go to downloads. Go into Other Releases and download what version you want with respect to your OS and 32-bit or 64-bit.
Example:
node-vX.XX.X-OS-x64.tar.gz (64-bit)
node-vX.XX.X-OS-x86.tar.gz (32-bit)
Then, follow the instruction on the github.com. Building and installing Node.js
Another way is to use NVM, the Node Version Manager (it works in a very similar way to rvm for ruby). This allows to install and manage multiple versions of node. Here's a snippet (source):
Usage:
nvm install <version> Download and install a <version>
nvm use <version> Modify PATH to use <version>
nvm ls List versions (installed versions are blue)
You can also check this n. A Simple flavour of node binary management.
Update (as per comments):
If you have installed the nvm after node.js. You can check already installed by using nvm ls which lists already installed version(s) ready to use.
amolkulkarni#ubuntu:~$ nvm ls
current: v0.10.18
You should use Node Version Manager https://github.com/creationix/nvm

Resources