npm Error: Cannot find module 'semver'

Solution 1:

  1. I manually uninstalled node and npm:
    sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node /opt/local/include/node /opt/local/lib/node_modules 
    
    sudo rm -rf /usr/local/lib/node* ; sudo rm -rf /usr/local/include/node* ; sudo rm -rf /usr/local/bin/node*
    
    sudo apt-get purge nodejs npm
    
  2. I re-installed node and npm manually by downloading from Node.js:
    tar -xf node-v5.9.0-linux-x64.tar.xz
      sudo mv node-v5.9.0-linux-x64/bin/* /usr/local/bin/
      sudo mv node-v5.9.0-linux-x64/lib/node_modules/ /usr/local/lib/
    
    # Verify installation:
      node -v ; npm -v