Как удалить node js mac os полностью
Перейти к содержимому

Как удалить node js mac os полностью

  • автор:

How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

My version of node is always v0.6.1-pre even after I install brew node and NVM install v0.6.19. My node version is:

node -v v0.6.1-pre 

NVM says this (after I install a version of node for the first time in one bash terminal):

nvm ls v0.6.19 current: v0.6.19 

But when I restart bash, this is what I see:

nvm ls v0.6.19 current: v0.6.1-pre default -> 0.6.19 (-> v0.6.19) 

So where is this phantom node 0.6.1-pre version and how can I get rid of it? I’m trying to install libraries via NPM so that I can work on a project. I tried using BREW to update before NVM, using brew update and brew install node . I’ve tried deleting the «node» directory in my /usr/local/include and the «node» and «node_modules» in my /usr/local/lib . I’ve tried uninstalling npm and reinstalling it following these instructions. All of this because I was trying to update an older version of node to install the «zipstream» library. Now there’s folders in my users directory, and the node version STILL isn’t up to date, even though NVM says it’s using 0.6.19. Ideally, I’d like to uninstall nodejs, npm, and nvm, and just reinstall the entire thing from scratch on my system.

86.1k 30 30 gold badges 372 372 silver badges 348 348 bronze badges
asked Jun 24, 2012 at 13:40
Dominic Tancredi Dominic Tancredi
41.3k 7 7 gold badges 34 34 silver badges 50 50 bronze badges
Nov 2, 2017 at 19:53
/usr/bin/node is another one.
Jan 19, 2018 at 0:15
this might help for whoever installed node via pkg file. superuser.com/questions/36567/…
Jul 2, 2018 at 14:32

Mac 10.13.5 has got /Users/myusername/node_modules should I delete this folder as well ? I searched in this thread but nobody faced this issue it seems

Oct 29, 2018 at 6:02
@Pacerier even after following instruction in gist, still node and npm exists on Mac OS 10.13.5
Jul 22, 2019 at 10:47

35 Answers 35

Apparently, there was a /Users/myusername/local folder that contained a include with node and lib with node and node_modules . How and why this was created instead of in my /usr/local folder, I do not know.

Deleting these local references fixed the phantom v0.6.1-pre. If anyone has an explanation, I’ll choose that as the correct answer.

EDIT:

You may need to do the additional instructions as well:

sudo rm -rf /usr/local/,bin,share/man>/ 

which is the equivalent of (same as above).

sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp 

or (same as above) broken down.

To completely uninstall node + npm is to do the following:

  1. go to /usr/local/lib and delete any node and node_modules
  2. go to /usr/local/include and delete any node and node_modules directory
  3. if you installed with brew install node, then run brew uninstall node in your terminal
  4. check your Home directory for any local or lib or include folders, and delete any node or node_modules from there
  5. go to /usr/local/bin and delete any node executable

You may also need to do:

sudo rm -rf /opt/local/bin/node /opt/local/include/node /opt/local/lib/node_modules sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node.1 /usr/local/lib/dtrace/node.d 

Additionally, NVM modifies the PATH variable in $HOME/.bashrc , which must be reverted manually.

Then download nvm and follow the instructions to install node. The latest versions of node come with npm, I believe, but you can also reinstall that as well.

30.6k 41 41 gold badges 179 179 silver badges 317 317 bronze badges
answered Jun 24, 2012 at 14:04
Dominic Tancredi Dominic Tancredi
41.3k 7 7 gold badges 34 34 silver badges 50 50 bronze badges
I also had to rm -rf /Users/[homedir]/.npm .
Apr 18, 2014 at 17:05
Also needed to remove /Users/[homedir]/.nvm
– user623990
Jul 22, 2014 at 23:23
I also ran brew doctor and then brew prune to clean up a bunch of broken symlinks for NPM.
Sep 2, 2014 at 11:54

I threw together a script that I’ve now battle tested. Thanks @DominicTancredi this works great! gist.github.com/brock/5b1b70590e1171c4ab54

Sep 13, 2014 at 1:50
I also had to add: sudo rm -rf ~/.node-gyp . I had added it with MacPorts before I switched to brew.
Nov 15, 2014 at 15:22

For brew users, OSX:

brew uninstall node; # or `brew uninstall --force node` which removes all versions brew cleanup; rm -f /usr/local/bin/npm /usr/local/lib/dtrace/node.d; rm -rf ~/.npm; 
brew install node; which node # => /usr/local/bin/node export NODE_PATH='/usr/local/lib/node_modules' #  

You can run brew info node for more details regarding your node installs.

consider using NVM instead of brew

NVM (node version manager) is a portable solution for managing multiple versions of node

https://github.com/nvm-sh/nvm

> nvm uninstall v4.1.0 > nvm install v8.1.2 > nvm use v8.1.2 > nvm list v4.2.0 v5.8.0 v6.11.0 -> v8.1.2 system 

you can use this with AVN to automatically switch versions as you hop between different projects with different node dependencies.

answered Nov 13, 2014 at 22:19
random-forest-cat random-forest-cat
33.9k 12 12 gold badges 120 120 silver badges 99 99 bronze badges
How to set env vars so that node and npm are available after such install?
Sep 13, 2015 at 9:55

You may need to run brew with the --force flag to make sure all versions of node are removed: $ brew uninstall --force node

Oct 6, 2015 at 8:42

> "consider using NVM instead of brew"; Ironically you can install NVM with brew!; Great tip, thanks.

May 8, 2019 at 3:39
Using NVM helped.
Jul 3, 2019 at 17:16

After running brew uninstall --force node && brew cleanup , node --version and npm version are still returning a version

May 1, 2021 at 16:57

UPDATE: 23 SEP 2016 - Intel Macs 10.11.x and above

If you're afraid of running these commands.

First, create an intermediate file:

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom >> ~/filelist.txt 

Manually review your file (located in your home ~ folder)

 ~/filelist.txt 

Then delete the files:

cat ~/filelist.txt | while read f; do sudo rm /usr/local/$; done sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* 

Intel Macs 10.10.x and below

Thanks Lenar Hoyt

Gist Comment Source: gistcomment-1572198

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom | while read f; do sudo rm /usr/local/$; done sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* 

ORIGINAL: 7 JUL 2014

I know this post is a little dated but just wanted to share the commands that worked for me in Terminal when removing Node.js.

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/$; done sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* 

answered Jul 7, 2014 at 13:40
2,381 1 1 gold badge 16 16 silver badges 19 19 bronze badges

Whoa-- this is terrifying. At least the first "rm" isn't a "rm -rf", which, if there's a blank line on the outpur of sbom, would remove all of /usr/local. Before doing anything so heavyhanded, scrutinize the sbom output and where all these dirs came from and make sure you know exactly what you're removing.

Apr 24, 2015 at 1:45

I should add. if you've got a healthy self-preservation instinct, it should be extremely difficult for you to type or copy-paste that second command, which begins with "sudo rm -rf /", at all. One sneeze, or the cat jumps on your keyboard, and you've destroyed your filesystem.

Apr 24, 2015 at 6:14
It’s org.nodejs.node.pkg.bom instead of org.nodejs.pkg.bom .
Oct 10, 2015 at 18:48

@DonHatch copy the line without the first letter so it starts with udo.. and then prepend s before running it.

Oct 5, 2017 at 23:28

The lsbom command outputs relative paths so the script was trying to delete paths that looked like /usr/local/./node/yada . To remove the ./ prefix I used cut filter: lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom | cut -c 3- | while read f; do sudo rm /usr/local/$; done

Jan 18, 2020 at 4:29

Run following commands to remove node completely from system in MACOS

sudo rm -rf ~/.npm ~/.nvm ~/node_modules ~/.node-gyp ~/.npmrc ~/.node_repl_history sudo rm -rf /usr/local/bin/npm /usr/local/bin/node-debug /usr/local/bin/node /usr/local/bin/node-gyp sudo rm -rf /usr/local/share/man/man1/node* /usr/local/share/man/man1/npm* sudo rm -rf /usr/local/include/node /usr/local/include/node_modules sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /usr/local/lib/dtrace/node.d sudo rm -rf /opt/local/include/node /opt/local/bin/node /opt/local/lib/node sudo rm -rf /usr/local/share/doc/node sudo rm -rf /usr/local/share/systemtap/tapset/node.stp brew uninstall node brew doctor brew cleanup --prune-prefix 

After this I will suggest to use following command to install node using nvm (check https://github.com/nvm-sh/nvm for latest version)

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

Why nvm?
this is a good question, there will be projects requiring different versions of node,
i.e. A requires node version 12 while B requires node version 14. This version management of node is provided by nvm only.

1,664 11 11 silver badges 24 24 bronze badges
answered Jun 13, 2020 at 6:16
Akshay Vijay Jain Akshay Vijay Jain
13.8k 8 8 gold badges 64 64 silver badges 75 75 bronze badges
This worked for me in May 2021, using Mac OS: 10.15.6. Thank you 🙂
May 24, 2021 at 10:38
Why are you suggesting to use nvm to install node and not brew or npm?
Nov 1, 2021 at 16:08
Worked for me in November 2021, using Mac OS 11.5.2
Nov 4, 2021 at 23:18

Worked for me in March, 2022! This was the only working solution to completely remove all hidden Node binaries.

Mar 23, 2022 at 17:16

Works perfectly in July 2022 (I only tried this because of positive feedback in the comments, Thanks guys.)

Aug 16, 2022 at 19:43

On Mavericks I install it from the node pkg (from nodejs site) and I uninstall it so I can re-install using brew. I only run 4 commands in the terminal:

  1. sudo rm -rf /usr/local/lib/node_modules/npm/
  2. brew uninstall node
  3. brew doctor
  4. brew cleanup --prune-prefix

If there is still a node installation, repeat step 2. After all is ok, I install using brew install node

1,529 1 1 gold badge 15 15 silver badges 24 24 bronze badges
answered Jan 17, 2014 at 23:26
Pedro Polonia Pedro Polonia
2,614 3 3 gold badges 23 23 silver badges 31 31 bronze badges
1 worked, but 2 fails. I get "no such keg: usr/local/Cellar/node"
Feb 12, 2015 at 3:32
Yep, this is the best if you have are running Mavericks
Feb 21, 2017 at 16:18
I tried it but again getting same error Error: The brew link step did not complete successfully
Jul 20, 2018 at 2:54
Thanks, perfect except I had to add --force to brew uninstall
Oct 22, 2018 at 15:15

FYI: As of this writing - ->brew prune Error: Calling 'brew prune' is disabled! Use 'brew cleanup --prune-prefix' instead.

Mar 29, 2019 at 21:07

I have summarized the existing answers and made sure Node.js is COMPLETELY ERASED along with NPM.

Lines to copy to terminal:

brew uninstall node; which node; sudo rm -rf /usr/local/bin/node; sudo rm -rf /usr/local/lib/node_modules/npm/; brew doctor; brew cleanup --prune-prefix; 

6,585 3 3 gold badges 39 39 silver badges 59 59 bronze badges
answered Jan 23, 2020 at 16:28
4,694 1 1 gold badge 27 27 silver badges 32 32 bronze badges

I followed these steps and it seems to have worked. I still have directories in my root folder like .node-gyp/ , .npm/ , .npm-global/ , and .nvm/ . Can I delete these or should I keep them if I plan on reinstalling node?

Mar 30, 2020 at 17:25
of all things, you probably want to delete /node-gyp/
Jun 28, 2021 at 23:31

wrt brew uninstall node - if you had installed explicit node versions by appending @ then you also have to uninstall them using the same identifiers, node alone will not blanket them

Jan 27, 2022 at 10:07

despite running brew cleanup (with and without the --prune-prefix param) for a couple of times, brew doctor always finds the same leftovers over and over again

Jan 27, 2022 at 10:10

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/$; done sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* 
cd /usr/local/lib sudo rm -rf node* 
cd /usr/local/include sudo rm -rf node* 
brew uninstall node 
cd /usr/local/bin sudo rm -rf /usr/local/bin/npm ls -las 
sudo rm -rf /usr/local/share/man/man1/node.1 sudo rm -rf /usr/local/lib/dtrace/node.d sudo rm -rf ~/.npm 

21.7k 12 12 gold badges 74 74 silver badges 82 82 bronze badges
answered Jun 28, 2015 at 17:24
Johel Alvarez Johel Alvarez
775 8 8 silver badges 8 8 bronze badges

Removing node* is not a particularly safe way to proceed. There may be other binaries with that prefix.

Oct 10, 2015 at 19:28

Great, finally after 3 days, when every now and then there were npm issues, removed completely and reinstall using brew on my mac, works like a charm.

Aug 10, 2016 at 11:56

When fired first command getting can't open /var/db/receipts/org.nodejs.pkg.bom: No such file or directory **** Can't open /var/db/receipts/org.nodejs.pkg.bom. Please help

Jun 20, 2019 at 5:09

Even after doing these steps on Mac 10.13.5, still I could see npm and node what may be going wrong ?

Jul 22, 2019 at 10:54

downgrade node to 0.10.36

 sudo npm cache clean -f sudo npm install -g n sudo n 0.10.36 

upgrade node to stable v

 sudo npm cache clean -f sudo npm install -g n sudo n stable 

answered May 29, 2015 at 3:06
Anja Ishmukhametova Anja Ishmukhametova
1,535 16 16 silver badges 14 14 bronze badges
I just did this and oddly, it downgraded npm from 6.4.1 to 6.2.0.
Sep 4, 2018 at 23:09

I'm not sure if it's because I had an old version (4.4.5), or if it's because I used the official installer, but most of the files referenced in other answers didn't exist on my system. I only had to remove the following:

~/.node-gyp ~/.node_repl_history /usr/local/bin/node /usr/local/bin/npm /usr/local/include/node /usr/local/lib/dtrace/node.d /usr/local/lib/node_modules /usr/local/share/doc/node /usr/local/share/man/man1/node.1 /usr/local/share/systemtap/tapset/node.stp 

I decided to keep ~/.npm because I was planning on reinstalling Node with Homebrew.

answered Jan 25, 2017 at 18:42
Big McLargeHuge Big McLargeHuge
15k 11 11 gold badges 81 81 silver badges 109 109 bronze badges

This answer was made in 2012, so I'm sure it has some legacy-ness to it. Now, if new answers show up, I upvote them after reviewing if they're effective.

Feb 4, 2017 at 18:27

Complete uninstall Node.js on macOS Monterey version 12.0.1

To check the current node version installed on your system:

# node -v # v14.15.0 

Enter the given below commands to delete Node from your system:

# cd /usr/local/include # sudo rm -R node # cd ../lib # sudo rm -R node_modules # cd ../bin # sudo rm -R node 

to check that node doesn't exist anymore

# node -v # -bash: node: command not found 

Install Node.js on macOS Monterey version 12.0.1

  1. Download the LTS version of node from the official website
  1. Double click on the node-v16.13.1.pkg installation package and continue with the default settings
  2. Type node -v in your terminal to print the current installed version of node : v16.13.1 & npm -v to print the current npm version installed on your machine : 8.1.2

answered Dec 15, 2021 at 23:13
1,083 10 10 silver badges 21 21 bronze badges
my include folder is empty
Jan 16, 2022 at 7:10

Beware: this way you'll get EACCES: permission denied error when you try to install anything globally with npm install -g any-package-name . The official documentation (docs.npmjs.com/downloading-and-installing-node-js-and-npm) strongly recommends using Node version manager to install Node.js and npm.

May 4, 2022 at 1:58

Complete uninstall Nodejs on macOS Big Sur version 11.2.3 (20D91)

Introduction

First things first, I want to say thank you for sharing this trick @tonymtz.

My system is running macOS Big Sur version 11.2.3 (20D91) with nodejs Latest Current Version: 15.14.0 (includes npm 7.7.6) installed from the official website.

I tried to fully uninstall nodejs on my MacBook Pro in order to re-install it with homebrew package manager using:

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/$; done 

but I was facing an issue like @AhteshamShah mentioned in @JohelAlvarez's answer:

When fired first command getting: can't open /var/db/receipts/org.nodejs.pkg.bom: No such file or directory **** Can't open /var/db/receipts/org.nodejs.pkg.bom. – Ahtesham Shah Jun 20 '19 at 5:09

I dived into the original post linked by @JohelAlvarez, reading all the comments and I've found this comment from @e2tha-e:

@tonymtz On my installation of Node v4.0.0 on Yosemite 10.10.5, the first line needed to be lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom | while read f; do sudo rm /usr/local/$; done A different filename from org.nodejs.pkg.bom Otherwise, this worked like a charm!

@e2tha-e was right, on macOS Big Sur version 11.2.3 (20D91 ) with nodejs Latest Current Version: 15.14.0 (includes npm 7.7.6) installed from official website, the file name is not org.nodejs.pkg.bom but org.nodejs.node.pkg.bom .

You can check this when you cd /var/db/receipts/ && ls -la .

Solution for installation from Nodejs's official website

With your preferred Terminal, fully uninstall Nodejs from your system like this :

Option 1
  1. lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom | while read f; do sudo rm /usr/local/$; done
  2. sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
Option 2

Go to /var/db/receipts/ and delete any org.nodejs.*

  1. cd /var/db/receipts/ && ls -la
  2. sudo rm -rf org.nodejs.*

Go to /usr/local/lib and delete any node and node_modules

  1. cd /usr/local/lib && ls -la
  2. sudo rm -rf node*

Go to /usr/local/include and delete any node and node_modules directory

  1. cd /usr/local/include && ls -la
  2. sudo rm -rf node*

Check your $HOME directory for any "local" or "lib" or "include" folders, and delete any "node" or "node_modules" from there.

Go to /usr/local/bin and delete any node executable

  1. cd /usr/local/bin && ls -la
  2. sudo rm -rf /usr/local/bin/npm
  3. sudo rm -rf /usr/local/bin/node

You may need to do this too:

  1. sudo rm -rf /usr/local/share/man/man1/node.1
  2. sudo rm -rf /usr/local/lib/dtrace/node.d
  3. sudo rm -rf ~/.npm

After that, you can check if there is still node in your system with which node or find all occurrences for node in your system.

Tips

  1. Search where node files are with find / -name 'node' | sed -E 's|/[^/]+$||' |sort -u
  2. Before running shared code by others, check your directories before to make sure you write the right file name.

19.9k 18 18 gold badges 102 102 silver badges 189 189 bronze badges
answered Apr 8, 2021 at 10:08
Yohan W. Dunon Yohan W. Dunon
502 10 10 silver badges 18 18 bronze badges

Today, October 2021, the BOM for node-v17.0.0.pkg (which also supports M1) includes ./usr/local prefixes. Hence, the rm command in "Option 1" does not need to add that prefix for that version.

Oct 20, 2021 at 8:07

Steps to Uninstall NodeJS:

For MacOS Monterey with M1 chip, please follow the link below to uninstall node completely from the system. I have tried multiple ways but this one worked finally.

Additionally, please execute the following commands at the end to remove node related directories from bin folder.

sudo rm -R node-sass sudo rm -R npm sudo rm -R npx 

To verify that node is removed:

node --version 

It should say command not found.

Steps to Install NodeJS:

Enable Rosseta terminal on your Mac with M1 chip. How to enable Rosseta terminal

Use nvm (Node Version Manager) to install NodeJS on your machine. Why nvm?? Because you can run multiple versions of NodeJS (you can work with a new app as well as a Legacy app).

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash 

Create a .zshrc file if not exists.

touch ~/.zshrc 

Install node using nvm.

nvm install node # "node" is an alias for the latest version nvm install 14.7.0 # or 16.3.0, 12.22.1, etc 

To verify the number of NodeJS versions available:

nvm ls 

answered Dec 28, 2021 at 13:04
Prateek Kumar Dalbehera Prateek Kumar Dalbehera
2,244 3 3 gold badges 24 24 silver badges 30 30 bronze badges

brew uninstall node 

I had to know which node

which node 

then remove that

rm -rf /usr/local/bin/node 

answered Apr 17, 2019 at 20:06
2,448 3 3 gold badges 31 31 silver badges 40 40 bronze badges

  • Delete node and/or node_modules from /usr/local/lib
ex code: cd /usr/local/lib sudo rm -rf node sudo rm -rf node_modules 

4,343 8 8 gold badges 24 24 silver badges 34 34 bronze badges
answered Mar 28, 2019 at 16:00
Rajiv Singh Rajiv Singh
988 1 1 gold badge 9 9 silver badges 14 14 bronze badges
I also had to remove node@6 from /usr/local/opt/
Jun 4, 2019 at 19:07

$node --version v11.1.0 $nvm deactivate $nvm uninstall v11.1.0 

38.2k 20 20 gold badges 92 92 silver badges 95 95 bronze badges
answered Nov 5, 2018 at 8:44
Inês Gomes Inês Gomes
4,343 1 1 gold badge 24 24 silver badges 32 32 bronze badges
But only if you have nvm installed.
Nov 17, 2018 at 8:35
Dec 13, 2018 at 20:00

If you have already installed nvm then execute the following commands

  • nvm deactivate - This will remove /.nvm/*/bin from $PATH
  • nvm list - To list out all the versions of node installed in the system
  • nvm uninstall in you can specify all the versions you want to uninstall.

It is always a good that you install node using nvm and uninstall using nvm rather than brew .

This solution worked for me.

  • which node to know the path of node installed in your system. You can rm this directory to uninstall node manually. Then you may need to adjust the PATH file accordingly.

answered May 11, 2019 at 5:57
Akhil Nadh PC Akhil Nadh PC
574 1 1 gold badge 7 7 silver badges 24 24 bronze badges

Expanding on Dominic Tancredi's awesome answer, I've rolled this into a bash package and stand-alone script. If you are already using the "Back Package Manager" called bpkg you can install the script by running:

bpkg install -g brock/node-reinstall 

Or you can have a look at the script on Github at brock/node-reinstall. The script allows you to re-install node using nvm or nave, and to specify a node version as your default.

1 1 1 silver badge
answered Mar 11, 2015 at 16:18
2,302 7 7 gold badges 27 27 silver badges 30 30 bronze badges

I was about to post this, and see that the author himself posted the best possible answer to the problem: use node-reinstall once and you'll never look back. Got me hitting the ground running and ready for more development! Cheers for this @brockangelo!

Oct 18, 2015 at 9:51

Warning. the node-reinstall script contains this line: sudo rm -rf $HOME/ So if you happen to independently have a directory of that name in your $HOME (as I do), it's going to get clobbered!

May 26, 2016 at 23:47

Additional to the main answer I needed to remove all npm instances found in:

rm -rf /usr/local/share/man/man1/npm* 

25.8k 11 11 gold badges 71 71 silver badges 103 103 bronze badges
answered Jan 9, 2015 at 22:02
Carlos Pérez Priego Carlos Pérez Priego
153 2 2 silver badges 9 9 bronze badges
This should be a comment on the appropriate answer, not a new answer.
Nov 21, 2017 at 1:40

maybe you need to make

hash -r 

it helps with problem of symlink

$ node -v $ bash: /opt/local/bin/node: No such file or directory 

answered Sep 20, 2014 at 12:13
111 1 1 silver badge 4 4 bronze badges

The best way is to download an installer package: .pkg on mac. Prefer the latest stable version.

Here is the link: Node.js

This package will eventually overwrite the previous version and set environment variables accordingly. Just run the installer and its done within a few clicks.

answered Aug 24, 2018 at 23:52
vkrishna17 vkrishna17
906 10 10 silver badges 17 17 bronze badges

I have been hit by an issue during uninstall of Node.js on my mac. I had some strange behavior like npm is still there even after having to remove it with all this.

It was because I had an old install done with macport. So you also have to uninstall it using port:

sudo port uninstall nodejs 

It may have installed many different versions of Node.js so uninstall them all (one by one).

5,380 5 5 gold badges 42 42 silver badges 66 66 bronze badges
answered Aug 14, 2013 at 20:26
5,145 5 5 gold badges 38 38 silver badges 45 45 bronze badges

This is exactly what happened to me 🙂 thx for your addendum answer. Well, I started having several versions of Cordova, and one npm could not remove the one Cordova and vice versa.

Feb 28, 2015 at 12:41

You can clone https://github.com/brock/node-reinstall and run the simple command as given in the repository.After that just restart your system.
This is the simplest method and also worked for me.

answered Dec 9, 2016 at 11:00
2,052 4 4 gold badges 27 27 silver badges 38 38 bronze badges

I had installed Node.js from source downloaded from the git repository. I installed with:

./configure $ make $ sudo make install 

Because the make file supports it, I can do:

$ sudo make uninstall 

answered Jul 22, 2015 at 20:11
Dave Kuhlman Dave Kuhlman
99 5 5 bronze badges
How to run it parallel? say i want to run 2 versions?
– user285594
Nov 10, 2016 at 22:50

As a companion to the answers explaining cleanup and install via homebrew, I found that homebrew itself provided clear indications of the symlink clashes.

Unfortunately it provides these one by one as it encounters them, so it is a little laborious, but it does seem to find all the clashes and was the only way I could get a clean install with homebrew.

Essentially, the process is:

  1. use homebrew to uninstall node
  2. clean homebrew
  3. use homebrew to install node and note any flagged clashing file
  4. delete the flag clashing file (or whole directory if it is a 'node' directory)
  5. goto step 1 until you get a clean install

Here is a screen output from the last steps of my install - you can see it results in a clean install (eventually. ):

computer1:DevResources user1$ brew install node Updating Homebrew. ==> Downloading https://homebrew.bintray.com/bottles/node-13.1.0.mojave.bottle.tar.gz Already downloaded: /Users/user1/Library/Caches/Homebrew/downloads/da904f1fdab6f6b2243a810b685e67b29a642c6e945f086e0022323a37fe85f9--node-13.1.0.mojave.bottle.tar.gz ==> Pouring node-13.1.0.mojave.bottle.tar.gz Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink share/systemtap/tapset/node.stp Target /usr/local/share/systemtap/tapset/node.stp already exists. You may want to remove it: rm '/usr/local/share/systemtap/tapset/node.stp' To force the link and overwrite all conflicting files: brew link --overwrite node To list all files that would be deleted: brew link --overwrite --dry-run node Possible conflicting files are: /usr/local/share/systemtap/tapset/node.stp /usr/local/lib/dtrace/node.d ==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> Summary �� /usr/local/Cellar/node/13.1.0: 4,591 files, 54.2MB computer1:DevResources user1$ rm '/usr/local/share/systemtap/tapset/node.stp' computer1:DevResources user1$ brew uninstall node Uninstalling /usr/local/Cellar/node/13.1.0. (4,591 files, 54.2MB) computer1:DevResources user1$ brew cleanup computer1:DevResources user1$ brew install node Updating Homebrew. ==> Downloading https://homebrew.bintray.com/bottles/node-13.1.0.mojave.bottle.tar.gz Already downloaded: /Users/user1/Library/Caches/Homebrew/downloads/da904f1fdab6f6b2243a810b685e67b29a642c6e945f086e0022323a37fe85f9--node-13.1.0.mojave.bottle.tar.gz ==> Pouring node-13.1.0.mojave.bottle.tar.gz Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink lib/dtrace/node.d Target /usr/local/lib/dtrace/node.d already exists. You may want to remove it: rm '/usr/local/lib/dtrace/node.d' To force the link and overwrite all conflicting files: brew link --overwrite node To list all files that would be deleted: brew link --overwrite --dry-run node Possible conflicting files are: /usr/local/lib/dtrace/node.d ==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> Summary �� /usr/local/Cellar/node/13.1.0: 4,591 files, 54.2MB computer1:DevResources user1$ rm '/usr/local/lib/dtrace/node.d' computer1:DevResources user1$ computer1:DevResources user1$ brew uninstall node Uninstalling /usr/local/Cellar/node/13.1.0. (4,591 files, 54.2MB) computer1:DevResources user1$ brew cleanup computer1:DevResources user1$ brew install node Updating Homebrew. ==> Downloading https://homebrew.bintray.com/bottles/node-13.1.0.mojave.bottle.tar.gz Already downloaded: /Users/user1/Library/Caches/Homebrew/downloads/da904f1fdab6f6b2243a810b685e67b29a642c6e945f086e0022323a37fe85f9--node-13.1.0.mojave.bottle.tar.gz ==> Pouring node-13.1.0.mojave.bottle.tar.gz ==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> Summary �� /usr/local/Cellar/node/13.1.0: 4,591 files, 54.2MB computer1:DevResources user1$ node -v v13.1.0 

How to uninstall Node.js on a Mac

Node.js is an open-source runtime environment used by developers to create networked programs and web servers. The way to install Node.js on a Mac is differently than the regular method for installing applications on the system. Therefore, when you need to uninstall Node.js, you might be confused. That’s why we’ve prepared a step-by-step guide explaining how to uninstall Node on a Mac.

Removing Node on Mac

  1. Where is Node installed on your Mac?
  2. How to check what version of Node you have
  3. How to uninstall Node.js from a Mac
  4. How to quickly uninstall apps from a Mac

The quickest way to uninstall any application on a Mac

If you want to uninstall applications completely (including all their support files) from your Mac, it is not enough to just drag and drop their icons into the Trash bin. That would leave the support files still on your disk.
You can find those leftover files manually; however, you can also use a special utility called App Cleaner & Uninstaller from Nektony, which automatically finds all the service files each application has left on your Mac and helps you uninstall the programs completely without leaving a single file behind. You can try the application for free.

App Cleaner & Uninstaller

Where is Node installed on your Mac?

To uncover where Node.js is installed on a Mac, first, you should try to remember how you installed it. Depending on that, Node’s files can be stored in different locations on your Mac.
If you downloaded the installer file from the Nodejs.org official website, you should look for the software support files in the following locations:

  • /usr/local/bin
  • /usr/local/lib
  • /usr/local/include
  • /usr/local/lib/dtrace
  • /usr/local/share/doc
  • /usr/local/share/man/man1
  • /usr/local/systemtap/tapset

Finder showing Node files

If you used NVM to install Node, you could find its support files in the .nvm hidden folder within your Home folder.

How to check what version of Node you have

You will need the Terminal command line to check the version of Node you have on your Mac. Follow these steps:

  1. Open the Terminal from Launchpad or the Applications folder.
  2. Copy and paste the following commands into the Terminal window:
    • node -v
    • npm -v
  3. You will then see which Node version is installed on your system.

Terminal window showing the command to check the Node version

How to uninstall Node.js from a Mac

The steps to remove Node.js from your Mac again depend on how you installed it. You can also delete Node.js on Mac using the Terminal command line or manually find and remove its files from your computer.

Here’s how to uninstall Node on Mac that was installed using Homebrew

  1. Open Terminal from Launchpad or the Applications folder.
  2. Run the following command in Terminal:

brew uninstall –force node

Terminal window showing the command to uninstall Node.js

How to uninstall Node installed using NVM

  1. Launch Terminal.
  2. Type the following command and press Enter (Return).

Terminal window showing the command to uninstall Node from your Mac

Note: You need to type the Node version number used on your Mac. Above, you can find the guide on how to check the version.

Uninstalling Node.js from your Mac manually

For this method, you will need to manually find and remove all files associated with Node. Here is how:

  1. Open Finder.
  2. Press the Cmd+Shift+G shortcut.
  3. In the search field, type /usr/local/lib and press Enter.
  4. Finder will show this location. Find the files or folder with Node in their names and move them into the Trash.
  5. Go also to the locations listed below and remove all node and node_modules from there:
    • /usr/local/include/node
    • /usr/local/include/node_modules
    • /usr/local/lib/node
    • /usr/local/lib/node_modules
    • /usr/local/bin/node
    • /usr/local/bin/node_modules
    • /usr/local/bin/node-gyp
    • /usr/local/share/man/man1/npm
    • /usr/local/lib/dtrace/node.d
    • /opt/local/bin/ node
    • /opt/local/include/node
    • /opt/local/lib/node_modules
    • /usr/local/share/doc/node
    • /usr/local/share/systemtap/tapset/node.stp

Finder showing Node support files

  • .npmrc
  • .npm
  • .node-gyp
  • .node_repl_history

Note that Node may have more or less support files depending on the software version you have.
Once you remove all of Node’s files, empty your Trash and restart your system. Node.js will be completely uninstalled from your Mac.

How to quickly uninstall apps from a Mac

Just like Node, every application creates support files to ensure its proper performance. To completely uninstall any application from Mac, you also have to remove all of its temporary files. By default, they should be stored in the Library folder. However, applications sometimes spread their files all over your disk.
That’s why we’re introducing App Cleaner & Uninstaller. It is software that helps you uninstall applications from your Mac completely and safely with a few clicks. Here’s how to uninstall Node using App Cleaner & Uninstaller:

  1. Download and launch App Cleaner & Uninstaller.
  2. Select the programs you want to remove.
  3. Click the Uninstall button and confirm the action.

Uninstalling apps from Mac

App Cleaner & Uninstaller will remove the program entirely, including all of its support files. If you wish to see these service files before removing the app, switch to Expert mode.
Additionally, App Cleaner & Uninstaller finds the leftovers of previously removed apps. To do this, switch to the Remaining Files section, where you will find support files of already uninstalled apps.

App Cleaner & Uninstaller showing remaining files

We recommend checking your system for unused software programs and useless service files left behind by removed apps so that you can free up space on your disk and optimize your Mac’s performance.

Conclusion

Uninstalling Node.js from a Mac involves a different process than the steps for removing sandboxed applications. This article provided two ways to do this. We also want to remind you that you can use App Cleaner & Uninstaller to wholly and quickly uninstall 1,500+ apps on macOS. You can download a free trial using the button below.

App Cleaner & Uninstaller Uninstall any Mac application in 2 minutes

Полное удаление и переустановка Node.js на Mac OS X

Uninstalling and reinstalling Node.js on Mac.

Проблема, с которой можно столкнуться при работе с Node.js, заключается в том, что после обновления версии Node.js через инструменты вроде brew или nvm, версия Node.js по-прежнему отображается как старая. Например, даже после установки Node.js v0.6.19, при проверке версии Node.js ( node -v ) отображается v0.6.1-pre. Это может создать проблемы при установке и работе с различными пакетами Node.js.

Приведем шаги, которые помогут полностью удалить Node.js, npm и nvm и переустановить все с нуля на Mac OS X.

Удаление Node.js, npm и nvm

  1. Удаление Node.js и npm: Для начала необходимо удалить уже установленные версии Node.js и npm. Для этого можно использовать следующие команды:
sudo rm -rf /usr/local/lib/node sudo rm -rf /usr/local/lib/node_modules sudo rm /usr/local/include/node sudo rm /usr/local/bin/node sudo rm /usr/local/share/man/man1/node.1 sudo rm /usr/local/lib/dtrace/node.d
  1. Удаление nvm: Для того, чтобы удалить nvm, следует удалить его каталог и удалить строку инициализации из .bashrc или .bash_profile (в зависимости от того, что используется):
rm -rf "$HOME/.nvm"

После этого необходимо открыть .bashrc или .bash_profile и удалить следующую строку:

[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

Переустановка Node.js и npm

После полного удаления Node.js, npm и nvm можно начать процесс переустановки.

  1. Самый простой способ установить Node.js и npm — скачать их с официального сайта Node.js. Здесь представлены последние стабильные версии Node.js и npm, которые можно скачать и установить, следуя инструкциям на сайте.

Переустановка nvm

  1. Для установки nvm можно использовать скрипт установки, доступный на странице nvm в GitHub:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
  1. После установки nvm можно установить нужную версию Node.js с помощью команды nvm install node .

В итоге, после всех этих шагов, Node.js, npm и nvm должны быть полностью удалены и переустановлены. Проверить версию Node.js можно с помощью команды node -v , а версию npm — с помощью команды npm -v .

Uninstall Node on MAC OS

Thank you. Your guide helped me to delete Node.js from MacBook Pro m1 pro. Now I can install nvm. Thank you, man.

Like comment:

1 like Like Comment button

Geek by day, an overthinker by night
Islamabad, Pakistan
COMSATS University, Islamabad
Information Security Engineer
Nov 13, 2019
Dropdown menu
Like comment:

2 likes Like Comment button

For further actions, you may consider blocking this person and/or reporting abuse

Read next

React roadmap ( with explanations and resources, all in one place)

arking115 - Oct 27

Guia Iniciante para Unidades de Medida em CSS

Davi Jonck - Oct 5

Using Heroicons with TailwindCSS

Necati Özmen - Oct 27

�� Looping Through JavaScript Objects with Different Approaches ��

Shameel Uddin - Oct 27

Geek by day, an overthinker by night
Islamabad, Pakistan
COMSATS University, Islamabad
Information Security Engineer
Nov 13, 2019

More from daud99

# vmwarefusion # mac # m1 # ubuntuinstallation
# nvm # node # mac # webdev

Once suspended, daud99 will not be able to comment or publish posts until their suspension is removed.

Submit & Suspend

Once unsuspended, daud99 will be able to comment and publish posts again.

Submit & Unsuspend

Once unpublished, all posts by daud99 will become hidden and only accessible to themselves.

If daud99 is not suspended, they can still re-publish their posts from their dashboard.

Unpublish all posts

Once unpublished, this post will become invisible to the public and only accessible to daud99.

They can still re-publish the post if they are not suspended.

Unpublish Post

Thanks for keeping DEV Community safe. Here is what you can do to flag daud99:

Make all posts by daud99 less visible

daud99 consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy.

Unflagging daud99 will restore default visibility to their posts.

Confirm Unflag

DEV Community — A constructive and inclusive social network for software developers. With you every step of your journey.

Built on Forem — the open source software that powers DEV and other inclusive communities.

Made with love and Ruby on Rails. DEV Community © 2016 - 2023.

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *