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

前端 未结 28 2189
难免孤独
难免孤独 2020-11-21 05:28

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:



        
相关标签:
28条回答
  • 2020-11-21 06:17

    After

    brew uninstall node
    

    I had to know which node

    which node
    

    then remove that

    rm -rf /usr/local/bin/node
    
    0 讨论(0)
  • 2020-11-21 06:18

    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;
    
    0 讨论(0)
  • 2020-11-21 06:18

    If you're unable to locate node just run whereis node and whereis npm and whereis nvm and you can remove the listed directories as needed.

    You'll also need to entirely close your terminal and reopen it for changes to take effect.

    0 讨论(0)
  • 2020-11-21 06:19

    I have been hit by an issue during uninstall of Node.js on my mac. I had some strange behavior like npm is still their even after having removing 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 install many different versions of Node.js so uninstall them all (one by one).

    0 讨论(0)
  • 2020-11-21 06:20

    For brew users, OSX:

    To remove:

    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;
    

    To install:

    brew install node;
    which node # => /usr/local/bin/node
    export NODE_PATH='/usr/local/lib/node_modules' # <--- add this ~/.bashrc
    

    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.

    0 讨论(0)
  • 2020-11-21 06:21

    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.

    0 讨论(0)
提交回复
热议问题