title: npm ERR! when installing Firebase Tools (errno -17, EEXIST: file already exists, symlink)
body: <p>I'm installing Firebase Tools for a new project on my new Macbook Air M1 and am running into the following issue on running the command <code>sudo npm install -g firebase-tools</code></p>
  <pre><code>npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
  npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
  npm WARN deprecated har-validator@5.1.5: this library is no longer supported
  npm ERR! code EEXIST
  npm ERR! syscall symlink
  npm ERR! path ../lib/node_modules/firebase-tools/lib/bin/firebase.js
  npm ERR! dest /usr/local/bin/firebase
  npm ERR! errno -17
  npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -&gt; '/usr/local/bin/firebase'
  npm ERR! File exists: /usr/local/bin/firebase
  npm ERR! Remove the existing file and try again, or run npm
  npm ERR! with --force to overwrite files recklessly.
  </code></pre>
  <p>I have googled a lot and have no leads...</p>
  <p>Also tried <code>npm clean cache</code>, <code>npm clean cache --force</code> and npm install with --force as recommended by the error message:</p>
  <p><code>npm install -g --force firebase-tools</code></p>
  <pre><code>npm WARN using --force I sure hope you know what you are doing.
  npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
  npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
  npm WARN deprecated har-validator@5.1.5: this library is no longer supported
  npm ERR! code EEXIST
  npm ERR! path /usr/local/bin/firebase
  npm ERR! Refusing to delete /usr/local/bin/firebase: node_modules/npm/bin/npm-cli.js symlink target is not controlled by npm /usr/local/bin
  npm ERR! File exists: /usr/local/bin/firebase
  npm ERR! Remove the existing file and try again, or run npm
  npm ERR! with --force to overwrite files recklessly.
  </code></pre>
  <p>Update: I've finally figured out how to find hidden files on a mac and deleted the offending file. I now get this error:</p>
  <pre><code>sudo npm install -g firebase-tools
  npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
  npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
  npm WARN deprecated har-validator@5.1.5: this library is no longer supported
  /usr/local/bin/firebase -&gt; /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js
  
  &gt; re2@1.16.0 install /usr/local/lib/node_modules/firebase-tools/node_modules/re2
  &gt; install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR || npm run rebuild
  
  Trying https://github.com/uhop/node-re2/releases/download/1.16.0/darwin-x64-83.br ...
  Writing to build/Release/re2.node ...
  Trying https://github.com/uhop/node-re2/releases/download/1.16.0/darwin-x64-83.gz ...
  Writing to build/Release/re2.node ...
  Building locally ...
  
  &gt; re2@1.16.0 rebuild /usr/local/lib/node_modules/firebase-tools/node_modules/re2
  &gt; node-gyp rebuild
  
  gyp WARN EACCES current user (&quot;nobody&quot;) does not have permission to access the dev dir &quot;/Users/macshac/Library/Caches/node-gyp/14.17.1&quot;
  gyp WARN EACCES attempting to reinstall using temporary dev dir &quot;/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp&quot;
  gyp WARN install got an error, rolling back install
  gyp WARN install got an error, rolling back install
  gyp ERR! configure error 
  gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp'
  gyp ERR! System Darwin 20.5.0
  gyp ERR! command &quot;/usr/local/bin/node&quot; &quot;/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js&quot; &quot;rebuild&quot;
  gyp ERR! cwd /usr/local/lib/node_modules/firebase-tools/node_modules/re2
  gyp ERR! node -v v14.17.1
  gyp ERR! node-gyp -v v5.1.0
  gyp ERR! not ok 
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! re2@1.16.0 rebuild: `node-gyp rebuild`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the re2@1.16.0 rebuild script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  (node:11071) UnhandledPromiseRejectionWarning: 1
  (Use `node --trace-warnings ...` to show where the warning was created)
  (node:11071) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
  (node:11071) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  
  &gt; protobufjs@6.11.2 postinstall /usr/local/lib/node_modules/firebase-tools/node_modules/protobufjs
  &gt; node scripts/postinstall
  
  + firebase-tools@9.16.0
  added 694 packages from 431 contributors in 32.015s
  </code></pre>
  <p>(It also doesn't work without <code>sudo</code>)</p>