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

前端 未结 28 2185
难免孤独
难免孤独 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:01

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

    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.

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

    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/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
    

    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.

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

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

    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.

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

    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
    
    0 讨论(0)
提交回复
热议问题