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

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

    @lfender6445 answer worked just fine for me to uninstall

    Now to reinstall, I had problems installing the last version instead of the most stable one, so to install a specific node version you should do:

    brew install node@10 // 10 is the version I want
    brew link node@10
    
    0 讨论(0)
  • 2020-11-21 06:23

    This fixed it for me Fixing npm On Mac OS X for Homebrew Users. And it does not require too many steps.

    Just go to the solution part if you don't care about the why.

    Here is the relevant part for convenience:

    Solution

    This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

    Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

    Run the following commands to remove all existing global npm modules, uninstall node & npm, re-install node with the correct defaults, configure the location for global npm modules to be installed, and then install npm as its own pacakge.

    rm -rf /usr/local/lib/node_modules
    brew uninstall node
    brew install node --without-npm
    echo prefix=~/.npm-packages >> ~/.npmrc
    curl -L https://www.npmjs.com/install.sh | sh
    

    Node and npm should be correctly installed at this point. The final step is to add ~/.npm-packages/bin to your PATH so npm and global npm packages are usable. To do this, add the following line to your ~/.bash_profile:

    export PATH="$HOME/.npm-packages/bin:$PATH"
    

    Now you can re-install any global npm packages you need without any problems.

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

    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/${f}; done
     
    sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
    

    UPDATE: 23 SEP 2016


    If you're afraid of running these commands...

    Thanks to jguix for this quick tutorial.

    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/${f}; done
    
    sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
    

    For 10.10.5 and above

    Thanks Lenar Hoyt

    Gist Comment Source: gistcomment-1572198

    Original Gist: TonyMtz/d75101d9bdf764c890ef

    lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.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.*
    
    0 讨论(0)
  • 2020-11-21 06:25

    Worked for me.

    $node --version
    
    v11.1.0
    
    $nvm deactivate
    
    $nvm uninstall v11.1.0
    
    0 讨论(0)
提交回复
热议问题