How do I completely uninstall Node.js, and reinsta

2018-12-31 02:08发布

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.

18条回答
梦醉为红颜
2楼-- · 2018-12-31 02:27

First of all, you need to deactivate node: (mac) after install new node version.

nvm deactivate

This is removed /Users/user_name/.nvm/*/bin from $PATH

And after that node was updated

node --version
v10.9.0
查看更多
步步皆殇っ
3楼-- · 2018-12-31 02:28

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
查看更多
时光乱了年华
4楼-- · 2018-12-31 02:29
  1. First:

    lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do  sudo rm /usr/local/${f}; done
    
    sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
    
  2. To recap, the best way (I've found) to completely uninstall node + npm is to do the following:

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

    cd /usr/local/lib
    
    sudo rm -rf node*
    
  3. go to /usr/local/include and delete any node and node_modules directory

    cd /usr/local/include
    
    sudo rm -rf node*
    
  4. if you installed with brew install node, then run brew uninstall node in your terminal

    brew uninstall node
    
  5. 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

    cd /usr/local/bin
    
    sudo rm -rf /usr/local/bin/npm
    
    ls -las
    
  6. You may need to do the additional instructions as well:

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

Source: tonyMtz

查看更多
何处买醉
5楼-- · 2018-12-31 02:30

(server: ubuntu 14)

1.) install nvm (node version manager) https://github.com/creationix/nvm

2.) nvm install node

3.) npm -v (inquire npm version => 3.8.6)

4.) node -v (inquire node version => v6.0.0)

查看更多
心情的温度
6楼-- · 2018-12-31 02:34

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.

查看更多
余生无你
7楼-- · 2018-12-31 02:34

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
查看更多
登录 后发表回答