Home > Blockchain >  npm uninstall not working in Mac terminal
npm uninstall not working in Mac terminal

Time:03-13

I tried the below commands to uninstall node version 14, but its not working. Please help hereenter image description here

CodePudding user response:

New Version

If you want to install a new version of Node.js, then you can simply download it from the website (nodejs.org).

When you install a new version and run the installer, it will automatically remove the old version.

Remove Node.js (and npm)

If you want to remove Node.js and npm altogether, then you need to follow the steps below.

  1. Open the terminal, and navigate to the home directory.

  2. Type the following commands (ignore the $; they are just to indicate a new command to enter).

    $ cd /usr
    $ cd local
    $ cd include
    $ ls
    
  3. Then, delete the Node directory by typing in the following command.

    $ sudo rm -rf node
    
  4. Go back to the local directory, and enter the lib directory by entering the following commands.

    $ cd ..
    $ cd lib
    
  5. Delete the node_modules folder by entering the following command.

    $ sudo rm -rf node-modules
    
  6. To delete Node from the bin directory, type in the following commands.

    $ cd ..
    $ cd bin
    $ sudo rm -rf node
    
  7. Note: npm and npx can both be deleted from the bin directory.

Thanks to dev.to for the steps!

CodePudding user response:

I've been working with node and macos for many years, and I've moved from node installation to node installation using nvm, which allows me to easily switch and install different versions of node.

You can try removing node this way, in case you installed it with brew

brew uninstall --ignore-dependencies node 
brew uninstall --force node 

Bonus - Managing multiple versions of node by installing nvm

brew update 
brew install nvm 
mkdir ~/.nvm 

Then update your bash profile or zsh_profile

nano ~/.bash_profile 

Add the following content

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

On the command line, update your profile (bash/zsh)

source ~/.bash_profile

Installing multiple versions of node

nvm install node12
nvm install node14
nvm install node16

To use a specific version of node (e.g 16)

nvm use 16
  • Related