codedamn

How to uninstall node.js from mac

How to uninstall node.js from mac

Node.js is a JavaScript runtime environment that you would have obviously known, as you are already trying to uninstall it from mac. Jokes apart, the foremost thing you should know before the uninstallation of the node.js is whether node.js is installed in your system. The following commands are to be entered:

# node -v
Most likely you are going to get the version of the node which is installed on your mac, one of which is given below.
# v16.13.1
You are going to get the below output if node.js is not installed in your system.
# node: command not found
After you confirm the presence of the installed node, the next part is to delete it. We have multiple ways of doing it. Let us now discuss each way in detail.

Command Method

The following commands are to be entered to uninstall node.js from your system:
#① cd /usr/local/include
#② sudo rm -R node
#③ cd ../lib
#④ sudo rm -R node_modules
#⑤ cd ../bin
#⑥ sudo rm -R node


With this, the wholesome work of uninstalling the node.js from your system gets completed. The way of confirming its uninstallation is to enter the following command:
# node -v
The output shown below confirms its uninstallation:
# node: command not found


Now let us understand what exactly did each of the command lines contribute to the uninstallation process

cd /usr/local/include
We generally use the cd command to alter the present working directory. The local directory holds all the installed applications locally. With include in the command, we refer to the local C header files.

sudo rm -R node
Sudo stands for Super User DO. The sudo command allows users to complete tasks without logging in as root users. We use the rm -R <directory-name> command to remove a directory, subdirectories, and all the files it contains recursively.

cd ../lib
The command “..” is used to raise the directory one level upward from the current directory or to the parent directory of the current directory. With this command, we move to the local libraries directory.

sudo rm -R node_modules
With this command, we remove the encapsulated code that communicates with an external application i.e modules related to the node from the library directory.

cd ../bin
With this command, we move from the local libraries directory to the local binaries directory.

sudo rm -R node
With this command, we complete the task of removing node.js from the local binaries directory without logging in as a root user.
With the cumulative working of each of the above command lines, we are successful in removing node from mac.

Node Version Manager(NVM) Method

It is one of the most convenient ways of uninstalling Node from your device. We also use Node Version Manager to install Node to your device. Sometimes there might be several versions of Node installed on your device. We can also use this method in uninstalling a particular version of Node.

The following command is to be entered:

nvm uninstall <version>

Example:

nvm uninstall v17.3.0

Homebrew Method

This method is one of the easiest methods of uninstalling Node. It deletes all the traces of Node in just one go. We just have to type the command as shown below.

brew uninstall node

We can also use Homebrew for installing Node by using the command shown below

brew install node

Manual method

We can delete Node from the device if we know all the locations where Node is present in the device. To know the location of Node in the device we can use the command shown below:

# which node

After knowing the location of all the places where Node is located, you can delete them manually from the finder.

Do check out our blog on Java vs Node.js – Creation, Usage, Performance, Projects, Frameworks & Ecosystem.

Hope you liked this article. If you have any queries or suggestions, do let us know in the comments! Check out the node.js course on Codedamn. You can use the playground on Codedamn to practice coding.

 

 

 

Learn programming on codedamn

Codedamn is an interactive coding platform with tons of sweet programming courses that can help you land your first coding job. Here's how:

Programming is one of the most in-demand jobs today. Learning to program can change your future. All the best!

Sharing is caring

Did you like what Vishnupriya wrote? Thank them for their work by sharing it on social media.