title: npm cannot find module 'semver' after reinstall
body: <p>I am using ubuntu 19.04.</p>
  
  <p>I am getting following error, when trying to do anything with npm</p>
  
  <pre><code>internal/modules/cjs/loader.js:638
      throw err;
      ^
  
  Error: Cannot find module 'semver'
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
      at Function.Module._load (internal/modules/cjs/loader.js:562:25)
      at Module.require (internal/modules/cjs/loader.js:692:17)
      at require (internal/modules/cjs/helpers.js:25:18)
      at Object.&lt;anonymous&gt; (/usr/share/npm/lib/utils/unsupported.js:2:14)
      at Module._compile (internal/modules/cjs/loader.js:778:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
      at Module.load (internal/modules/cjs/loader.js:653:32)
      at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
      at Function.Module._load (internal/modules/cjs/loader.js:585:3)
  </code></pre>
  
  <p>I have tried to apply different solutions from SO, but unfortunately they have not worked.</p>
  
  <p>It started happening after reinstalling NPM because of some errors I unfortunately cannot recreate.</p>
  
  <p>What I have tried </p>
  
  <pre><code>sudo apt purge nodejs
  sudo apt autoremove
  </code></pre>
  
  <p>after these two steps, npm is uninstalled. </p>
  
  <pre><code>npm -v
  bash: /usr/bin/npm: No such file or directory
  </code></pre>
  
  <p>I proceed to </p>
  
  <pre><code>sudo apt install nodejs
  </code></pre>
  
  <p>However the error occurs even after I have purged the files</p>
  
  <pre><code>User@User:/$ node -v
  v10.16.3
  User@User:/$ npm -v
  internal/modules/cjs/loader.js:638
      throw err;
      ^
  
  Error: Cannot find module 'semver'
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
      at Function.Module._load (internal/modules/cjs/loader.js:562:25)
      at Module.require (internal/modules/cjs/loader.js:692:17)
      at require (internal/modules/cjs/helpers.js:25:18)
      at Object.&lt;anonymous&gt; (/usr/share/npm/lib/utils/unsupported.js:2:14)
      at Module._compile (internal/modules/cjs/loader.js:778:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
      at Module.load (internal/modules/cjs/loader.js:653:32)
      at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
      at Function.Module._load (internal/modules/cjs/loader.js:585:3)
  </code></pre>
  
  <p>I have also tried following</p>
  
  <pre><code>sudo apt purge npm
  sudo apt purge nodejs
  sudo apt autoremove
  sudo apt install npm
  sudo apt install nodejs
  </code></pre>
  
  <pre><code>sudo rm -rf /usr/local/lib/node_modules
  sudo rm -rf ~/.npm
  brew uninstall --force node
  brew install node
  </code></pre>
  
  <p>It still yields the same error. The global files should be uninstalled with both of these approaches.</p>
  
  <p>To be certain I have searched the computer with and deleted anything if it looked like something relevant to node or npm.</p>
  
  <pre><code>sudo find / -type f -name "node"
  sudo find / -type f -name "node_modules"
  sudo find / -type f -name "npm"
  </code></pre>
  
  <p>It is if something is carried on through the purging, perhaps some files communication with NPM yielding the error.</p>