title: EACCES: permission denied -- even with sudo
body: <p>I'm trying to update my Expo CLI, so as the CLI suggests, I run <code>npm install --global expo-cli</code> which as I predict gives me access errors:</p>
  
  <pre><code>npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
  npm WARN @expo/dev-tools@0.5.19 requires a peer of @expo/xdl@^53.8.0 but none is installed. You must install peer dependencies yourself.
  npm WARN ts-pnp@1.1.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
  
  npm ERR! path /usr/local/lib/node_modules
  npm ERR! code EACCES
  npm ERR! errno -13
  npm ERR! syscall access
  npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
  npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
  npm ERR!   stack:
  npm ERR!    "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
  npm ERR!   errno: -13,
  npm ERR!   code: 'EACCES',
  npm ERR!   syscall: 'access',
  npm ERR!   path: '/usr/local/lib/node_modules' }
  npm ERR! 
  npm ERR! The operation was rejected by your operating system.
  npm ERR! It is likely you do not have the permissions to access this file as the current user
  npm ERR! 
  npm ERR! If you believe this might be a permissions issue, please double-check the
  npm ERR! permissions of the file and its containing directories, or try running
  npm ERR! the command again as root/Administrator (though this is not recommended).
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /Users/TuzMacbookPro2017/.npm/_logs/2019-06-06T19_38_50_079Z-debug.log
  </code></pre>
  
  <p>So I run with <code>sudo</code>. But then I get a whole bunch more other access errors:</p>
  
  <pre><code>$sudo  npm install --global expo-cli
  
  &gt; @expo/traveling-fastlane-darwin@1.9.4 preinstall /usr/local/lib/node_modules/expo-cli/node_modules/@expo/traveling-fastlane-darwin
  &gt; node platform.js
  
  /usr/local/bin/expo -&gt; /usr/local/lib/node_modules/expo-cli/bin/expo.js
  /usr/local/bin/expo-cli -&gt; /usr/local/lib/node_modules/expo-cli/bin/expo.js
  
  &gt; fsevents@1.2.9 install /usr/local/lib/node_modules/expo-cli/node_modules/fsevents
  &gt; node install
  
  node-pre-gyp WARN Using request for node-pre-gyp https download 
  node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.9 and node@11.12.0 (node-v67 ABI, unknown) (falling back to source compile with node-gyp) 
  node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib' 
  gyp ERR! configure error 
  gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/build'
  gyp ERR! System Darwin 18.6.0
  gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v67"
  gyp ERR! cwd /usr/local/lib/node_modules/expo-cli/node_modules/fsevents
  gyp ERR! node -v v11.12.0
  gyp ERR! node-gyp -v v3.8.0
  gyp ERR! not ok 
  node-pre-gyp ERR! build error 
  node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
  node-pre-gyp ERR! stack     at ChildProcess.&lt;anonymous&gt; (/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
  node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
  node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:988:16)
  node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
  node-pre-gyp ERR! System Darwin 18.6.0
  node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
  node-pre-gyp ERR! cwd /usr/local/lib/node_modules/expo-cli/node_modules/fsevents
  node-pre-gyp ERR! node -v v11.12.0
  node-pre-gyp ERR! node-pre-gyp -v v0.12.0
  node-pre-gyp ERR! not ok 
  Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
  
  &gt; iltorb@2.4.3 install /usr/local/lib/node_modules/expo-cli/node_modules/iltorb
  &gt; node ./scripts/install.js || node-gyp rebuild
  
  WARN install EACCES: permission denied, access '/Users/TuzMacbookPro2017/.npm'
  gyp ERR! configure error 
  gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/expo-cli/node_modules/iltorb/build'
  gyp ERR! System Darwin 18.6.0
  gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
  gyp ERR! cwd /usr/local/lib/node_modules/expo-cli/node_modules/iltorb
  gyp ERR! node -v v11.12.0
  gyp ERR! node-gyp -v v3.8.0
  gyp ERR! not ok 
  
  &gt; sharp@0.22.1 install /usr/local/lib/node_modules/expo-cli/node_modules/sharp
  &gt; (node install/libvips &amp;&amp; node install/dll-copy &amp;&amp; prebuild-install) || (node-gyp rebuild &amp;&amp; node install/dll-copy)
  
  info sharp Using cached /Users/TuzMacbookPro2017/.npm/_libvips/libvips-8.7.4-darwin-x64.tar.gz
  ERR! sharp EACCES: permission denied, mkdir '/usr/local/lib/node_modules/expo-cli/node_modules/sharp/vendor'
  info sharp Attempting to build from source via node-gyp but this may fail due to the above error
  info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
  gyp ERR! configure error 
  gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/expo-cli/node_modules/sharp/build'
  gyp ERR! System Darwin 18.6.0
  gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
  gyp ERR! cwd /usr/local/lib/node_modules/expo-cli/node_modules/sharp
  gyp ERR! node -v v11.12.0
  gyp ERR! node-gyp -v v3.8.0
  gyp ERR! not ok 
  npm WARN @expo/dev-tools@0.5.19 requires a peer of @expo/xdl@^53.8.0 but none is installed. You must install peer dependencies yourself.
  npm WARN ts-pnp@1.1.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/traveling-fastlane-linux@1.9.4 (node_modules/expo-cli/node_modules/@expo/traveling-fastlane-linux):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/traveling-fastlane-linux@1.9.4: wanted {"os":"win32,linux","arch":"any"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-win32-x64@2.2.8-beta.1 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-win32-x64):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-win32-x64@2.2.8-beta.1: wanted {"os":"win32","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-win32-ia32@2.2.8-beta.1 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-win32-ia32):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-win32-ia32@2.2.8-beta.1: wanted {"os":"win32","arch":"ia32"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-sunos-x64@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-sunos-x64):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-sunos-x64@2.2.8: wanted {"os":"sunos","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-linux-x64@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-linux-x64):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-linux-x64@2.2.8: wanted {"os":"linux","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-linux-ia32@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-linux-ia32):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-linux-ia32@2.2.8: wanted {"os":"linux","arch":"ia32"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-linux-arm64@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-linux-arm64):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-linux-arm64@2.2.8: wanted {"os":"linux","arch":"arm64"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-linux-arm@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-linux-arm):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-linux-arm@2.2.8: wanted {"os":"linux","arch":"arm"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-freebsd-x64@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-freebsd-x64):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-freebsd-x64@2.2.8: wanted {"os":"freebsd","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-freebsd-ia32@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-freebsd-ia32):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-freebsd-ia32@2.2.8: wanted {"os":"freebsd","arch":"ia32"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-darwin-ia32@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-darwin-ia32):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/ngrok-bin-darwin-ia32@2.2.8: wanted {"os":"darwin","arch":"ia32"} (current: {"os":"darwin","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/expo-cli/node_modules/fsevents):
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 install: `node install`
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: iltorb@2.4.3 (node_modules/expo-cli/node_modules/iltorb):
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: iltorb@2.4.3 install: `node ./scripts/install.js || node-gyp rebuild`
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
  
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! sharp@0.22.1 install: `(node install/libvips &amp;&amp; node install/dll-copy &amp;&amp; prebuild-install) || (node-gyp rebuild &amp;&amp; node install/dll-copy)`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the sharp@0.22.1 install script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /Users/TuzMacbookPro2017/.npm/_logs/2019-06-06T19_36_32_721Z-debug.log
  </code></pre>
  
  <p>Oh, and here's the best part:</p>
  
  <pre><code>$expo start
  -bash: /usr/local/bin/expo: No such file or directory
  </code></pre>
  
  <p>Now I can't even use whatever older version I had. Help!</p>