title: sudo npm install --global fails without error message on Linux
body: <p>I'm attempting to install yarn using npm, as is recommended by the yarn project itself. At first I tried running <code>npm install --global yarn</code>, which failed due to inadequate permissions, so I tried again with <code>sudo npm install --global  yarn</code>.</p>
  <p>But that gave me the following result:</p>
  <pre><code>npm info it worked if it ends with ok
  npm verb cli [ '/usr/bin/node',
  npm verb cli   '/usr/bin/npm',
  npm verb cli   'install',
  npm verb cli   '--verbose',
  npm verb cli   '--global',
  npm verb cli   'yarn' ]
  npm info using npm@6.14.4
  npm info using node@v10.19.0
  npm verb npm-session 92d2a6de56a6da3f
  npm http fetch GET 304 https://registry.npmjs.org/yarn 194ms (from cache)
  npm timing stage:loadCurrentTree Completed in 249ms
  npm timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
  npm timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
  npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 3ms
  npm timing stage:loadIdealTree Completed in 7ms
  npm timing stage:generateActionsToTake Completed in 7ms
  npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
  npm verb lock using /root/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
  npm timing action:extract Completed in 75ms
  npm info lifecycle yarn@1.22.10~preuninstall: yarn@1.22.10
  npm info lifecycle yarn@1.22.10~uninstall: yarn@1.22.10
  npm verb unbuild rmStuff yarn@1.22.10 from /usr/local/lib/node_modules
  npm info lifecycle yarn@1.22.10~postuninstall: yarn@1.22.10
  npm timing action:unbuild Completed in 6ms
  npm timing action:remove Completed in 6ms
  npm timing action:finalize Completed in 2ms
  npm timing action:refresh-package-json Completed in 5ms
  npm info lifecycle yarn@1.22.10~preinstall: yarn@1.22.10
  
  &gt; yarn@1.22.10 preinstall /usr/local/lib/node_modules/yarn
  &gt; :; (node ./preinstall.js &gt; /dev/null 2&gt;&amp;1 || true)
  </code></pre>
  <p>The command exits with exit code 1. The same result occurs in an <code>sudo -i</code> shell. I added the <code>--verbose</code> flag to try to see what's going on, but there's still no discernible error message. And sure enough, yarn isn't installed when I try to run it or use <code>which</code> on it. I also checked <code>~/.npm/_logs</code> and there are no logs for this error, only logs for the permission errors I encountered when I tried to run it without <code>sudo</code>. Why is this failing?</p>
  <p>Using Ubuntu 20.04 LTS.</p>
  <p>Edit:</p>
  <p>I was able to find the relevant log file in <code>/root/.npm/_logs</code>. It showed this as the error message:</p>
  <pre><code>error Cannot find module './get-uid-gid.js'
  </code></pre>
  <p>How do I fix that?</p>