Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Mac OS : Error while running sudo npm install -g expo-cli --allow-root #412

Closed
ashishkamdar opened this issue Mar 9, 2019 · 33 comments
Closed
Labels
Installation The issue pertains to installing expo-cli OS: macOS The issue is occurring on macOS

Comments

@ashishkamdar
Copy link

ashishkamdar commented Mar 9, 2019

👋Hello, are you having an issue that looks like this? If so, jump straight to the answer with this link

Link to solution: #412 (comment)


Original post below

on my MAC OS I RUN THE FOLLOWING COMMAND:
I GET AN ERROR INSTALLING THE EXPO CLI. PLEASE HELP.
MacBook-Air:~ guest2$ sudo npm install -g expo-cli --allow-root

/usr/local/bin/expo -> /usr/local/lib/node_modules/expo-cli/bin/expo.js
/usr/local/bin/expo-cli -> /usr/local/lib/node_modules/expo-cli/bin/expo.js

fsevents@1.2.7 install /usr/local/lib/node_modules/expo-cli/node_modules/fsevents
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.7 and node@10.15.3 (node-v64 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 WARN EACCES user "root" does not have permission to access the dev dir "/Users/guest2/.node-gyp/10.15.3"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/.node-gyp"
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/expo-cli/node_modules/fsevents/.node-gyp'
gyp ERR! System Darwin 18.2.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-v64-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /usr/local/lib/node_modules/expo-cli/node_modules/fsevents
gyp ERR! node -v v10.15.3
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-v64-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack at ChildProcess. (/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:189:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:970:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Darwin 18.2.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 v10.15.3
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
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-v64-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/expo-cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)

iltorb@2.4.1 install /usr/local/lib/node_modules/expo-cli/node_modules/iltorb
node ./scripts/install.js || node-gyp rebuild

info looking for cached prebuild @ /Users/guest2/.npm/_prebuilds/7a4d46-iltorb-v2.4.1-node-v64-darwin-x64.tar.gz
http request GET https://github.com/MayhemYDG/iltorb/releases/download/v2.4.1/iltorb-v2.4.1-node-v64-darwin-x64.tar.gz
http 200 https://github.com/MayhemYDG/iltorb/releases/download/v2.4.1/iltorb-v2.4.1-node-v64-darwin-x64.tar.gz
info downloading to @ /Users/guest2/.npm/_prebuilds/7a4d46-iltorb-v2.4.1-node-v64-darwin-x64.tar.gz.7292-ee64a08b6ff71.tmp
info renaming to @ /Users/guest2/.npm/_prebuilds/7a4d46-iltorb-v2.4.1-node-v64-darwin-x64.tar.gz
info unpacking @ /Users/guest2/.npm/_prebuilds/7a4d46-iltorb-v2.4.1-node-v64-darwin-x64.tar.gz
WARN install EACCES: permission denied, mkdir '/usr/local/lib/node_modules/expo-cli/node_modules/iltorb/build'
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/guest2/.node-gyp/10.15.3"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/expo-cli/node_modules/iltorb/.node-gyp"
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/expo-cli/node_modules/iltorb/.node-gyp'
gyp ERR! System Darwin 18.2.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 v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN ts-pnp@1.0.1 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
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-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-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-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: @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-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-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-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/traveling-fastlane-linux@1.8.0 (node_modules/expo-cli/node_modules/@expo/traveling-fastlane-linux):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/traveling-fastlane-linux@1.8.0: wanted {"os":"win32,linux","arch":"any"} (current: {"os":"darwin","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/expo-cli/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 install: node install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: iltorb@2.4.1 (node_modules/expo-cli/node_modules/iltorb):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: iltorb@2.4.1 install: node ./scripts/install.js || node-gyp rebuild
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

@AdamJNavarro AdamJNavarro added Installation The issue pertains to installing expo-cli OS: macOS The issue is occurring on macOS labels Mar 12, 2019
@methodbox
Copy link

I am having the same issue. It appears to be related to node-gyp and looking for it in the wrong location. Still troubleshooting.

@vikascn
Copy link

vikascn commented Apr 4, 2019

I am seeing the same issue. Whats the resolution here ?

@AlexanderLyon
Copy link

Same issue here, any updates?

@methodbox
Copy link

The best solution I found, as this is related to some new permissions controls in macOS is to use option 2 here: https://github.com/mixonic/docs.npmjs.com/blob/master/content/getting-started/fixing-npm-permissions.md

This changes your default home folder for global modules, which may require reinstallation of others when it’s time to update, but won’t affect those already installed.

Works fine now, and also resolved a similar issue I had with Loopback.

@vikascn
Copy link

vikascn commented Apr 5, 2019

@methodbox , I followed the option 2 from the link. But doesn't seem to fix the issue for me.
I still see the above problem. My issue is however seen while creating react-native project and not while installing expo-cli.
Filed this issue : #490

@methodbox
Copy link

@vikascn Did you try removing create-react-app and reinstalling it after this change?

Also, you’ll need to exit your terminal to have this take effect as this is setting an env variable.

I also had the issue with CRA. This fixes the issue because you’re problem is caused by your user not having perms to the folder in question.

Sudo doesn’t fix this as it is then required for operations node-gyp is required for in a context where you can’t provide sudo.

This is due to a higher level system control of perms in macOS.

The solution is to move the node modules global folder to a folder within your home directory, which your user owns.

If you’re having issues after doing that properly your issue isn’t the same thing, unless you’re getting the same error in which case you did it wrong.

@methodbox
Copy link

methodbox commented Apr 9, 2019

edit - wrong issue

@chrisvoo
Copy link

I get the same error on Ubuntu, so I don't think it's strictly related to MacOS:

info looking for cached prebuild @ /home/ccastelli/.npm/_prebuilds/9ee718-iltorb-v2.4.2-node-v64-linux-x64.tar.gz
http request GET https://github.com/MayhemYDG/iltorb/releases/download/v2.4.2/iltorb-v2.4.2-node-v64-linux-x64.tar.gz
http 200 https://github.com/MayhemYDG/iltorb/releases/download/v2.4.2/iltorb-v2.4.2-node-v64-linux-x64.tar.gz
info downloading to @ /home/ccastelli/.npm/_prebuilds/9ee718-iltorb-v2.4.2-node-v64-linux-x64.tar.gz.29305-ad9fb8b059e4f.tmp
info renaming to @ /home/ccastelli/.npm/_prebuilds/9ee718-iltorb-v2.4.2-node-v64-linux-x64.tar.gz
info unpacking @ /home/ccastelli/.npm/_prebuilds/9ee718-iltorb-v2.4.2-node-v64-linux-x64.tar.gz
WARN install EACCES: permission denied, mkdir '/usr/local/lib/node_modules/expo-cli/node_modules/iltorb/build'
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 Linux 5.0.0-13-generic
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 v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

My system:

  • OS: Ubuntu 19.04 - 5.0.0-13-generic - x86_64
  • Node: v10.15.3
  • NPM: 6.9.0

@Divine1
Copy link

Divine1 commented May 8, 2019

i'm facing the same issue

OS macOS 10.14.4
node v10.15.3
npm 6.4.1

@pabloimrik17
Copy link

Same issue here.

System info:

OS: macOS 10.14.4
Node: 10.14.2
Npm: 6.9

@pabloimrik17
Copy link

Any update?

@Divine1
Copy link

Divine1 commented May 21, 2019

i was facing the same issue with the node version (refer the comment i posted in this thread before few days).

Then i downgraded the node,npm version to below configuration

npm 5.6.0
node 8.11.2

After using 8.11.2 the error disappeared. There is some problem while using expo with node 10.*

@methodbox
Copy link

methodbox commented May 21, 2019

Did anyone read my comment about moving your global folder to your home directory?

Not only does it fix this issue, it’s a more secure way to handle node modules globally and makes sense in a *nix environment.

You shouldn’t even be using —allow-root if everything is working correctly.

If you consider other libs like python, for example, your global modules would be accessible for all users, but only those with root perms could install them, unless they installed them in a directory to which they had rwx perms (like their home folder).

It also makes sense for you to do this from the standpoint of macOS as they have changed controls on some system-level perms and folders in a way similar to SELinux with System Integrity Protection.

There’s also literally no reason for you to have a node_modules folder that is in any location that requires sudo to access.

Moving it to your home directory makes sense and makes this a non-issue, and it works on Linux, too.

When running in production on a server, it works fine to have it available globally, but you should still not do this for security reasons and instead create a user folder for the system process user running the app and make sure the node user and process user have access to this, usually through group perms, and/or setguid.

@pitops
Copy link

pitops commented May 26, 2019

@methodbox thanks I used option 1 and sudo is not even needed now. Thank you

@methodbox
Copy link

methodbox commented May 26, 2019

@pitops I would encourage using the second option as it achieves the same thing but without modifying permissions on a folder in your root directory; instead it shares your home directory permissions.

Glad it worked, but I would use the more secure option. It’s an easy fix and doesn’t break any existing config, just requires a reinstall of anything global.

@pitops
Copy link

pitops commented May 28, 2019

@methodbox Yes you are right - I just needed a quick and dirty solution at the time. I will format that pc soon so its not going to be an issue.

@methodbox
Copy link

Hi.
I tried setting unsafe-perm to true and it worked.
So, the command is:
npm config set unsafe-perm true
Then I used sudo npm install -g expo-cli as usual.

I use nvm so I tested it on both 8.11 and 10.15 versions of Node.

Of course it works - it's allowing you to bypass all of the permissions safeguards and execute something in an unsafe manner (hence the flag unsafe-perm true).

Maybe read above and find a better solution.

Here's npm's own definition of what you're doing:

unsafe-perm§
Default: false if running as root, true otherwise
Type: Boolean
Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.

You're bypassing permissions checks and it's working because you're running as root, but that shouldn't be necessary.

@shadinaif
Copy link

Change global directory works perfectly on Ubuntu too (see first comment by methodbox above)

@Tomerl101
Copy link

sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local/lib/node_modules

and then reinstall expo-cli globaly works

@codergogoi
Copy link

Thank you @Tomerl101

The above trick is working for me. I am not sure is it a proper way to resolve this or not.

@methodbox
Copy link

@codergogoi

It’s a bad solution because it has security issues and could break things and your perms are likely to be reassigned in the future.

Read above to the multiple posts where I’ve suggested a better fix.

You simply need to move your npm global folder into your user’s home directory and then assign this using npm configuration as the default global folder.

@abalam666
Copy link

abalam666 commented Jun 9, 2019

And the (quick) answer stays : sudo npm i -g --unsafe-perm expo-cli
Never had problems since years on dev stations... but you should not use this trick on servers.

@tuzmusic
Copy link

tuzmusic commented Jun 18, 2019

@methodbox, I tried that step two method and it didn't help at all:

$ npm i -g expo-cli
npm WARN deprecated joi@14.0.4: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated @babel/polyfill@7.4.4: 🚨 As of Babel 7.4.0, this
npm WARN deprecated package has been deprecated in favor of directly
npm WARN deprecated including core-js/stable (to polyfill ECMAScript
npm WARN deprecated features) and regenerator-runtime/runtime
npm WARN deprecated (needed to use transpiled generator functions):
npm WARN deprecated 
npm WARN deprecated   > import "core-js/stable";
npm WARN deprecated   > import "regenerator-runtime/runtime";
npm WARN deprecated joi@11.4.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated topo@2.0.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@6.1.3: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated topo@3.0.3: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/inquirer
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/sockjs
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/@expo/traveling-fastlane-darwin
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/@expo/traveling-fastlane-linux
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/@expo
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/inquirer/node_modules
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso/node_modules
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/sockjs/node_modules
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules
npm WARN @expo/dev-tools@0.5.25 requires a peer of @expo/xdl@54.1.5 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 /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso'
npm ERR!  { [Error: EACCES: permission denied, access '/Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path:
npm ERR!    '/Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso' }
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/TuzsNewMacBook/.npm/_logs/2019-06-18T21_20_19_566Z-debug.log

Using sudo doesn't work either, with the errors others have described.

My ~/.profile by the way:

export "PATH=~/npm-global/bin:$PATH"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

@tuzmusic
Copy link

Also, I used the infamous sudo npm i -g --unsafe-perm expo-cli which succeeded.

However:

$ expo start
-bash: expo: command not found

What's wrong??

@methodbox
Copy link

methodbox commented Jun 18, 2019

@methodbox, I tried that step two method and it didn't help at all:

$ npm i -g expo-cli
npm WARN deprecated joi@14.0.4: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated @babel/polyfill@7.4.4: 🚨 As of Babel 7.4.0, this
npm WARN deprecated package has been deprecated in favor of directly
npm WARN deprecated including core-js/stable (to polyfill ECMAScript
npm WARN deprecated features) and regenerator-runtime/runtime
npm WARN deprecated (needed to use transpiled generator functions):
npm WARN deprecated 
npm WARN deprecated   > import "core-js/stable";
npm WARN deprecated   > import "regenerator-runtime/runtime";
npm WARN deprecated joi@11.4.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated topo@2.0.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@6.1.3: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated topo@3.0.3: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/inquirer
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/sockjs
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/@expo/traveling-fastlane-darwin
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/@expo/traveling-fastlane-linux
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/@expo
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/inquirer/node_modules
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso/node_modules
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/sockjs/node_modules
npm WARN checkPermissions Missing write access to /Users/TuzsNewMacBook/npm-global/lib/node_modules
npm WARN @expo/dev-tools@0.5.25 requires a peer of @expo/xdl@54.1.5 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 /Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso'
npm ERR!  { [Error: EACCES: permission denied, access '/Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path:
npm ERR!    '/Users/TuzsNewMacBook/npm-global/lib/node_modules/expo-cli/node_modules/csso' }
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/TuzsNewMacBook/.npm/_logs/2019-06-18T21_20_19_566Z-debug.log

Using sudo doesn't work either, with the errors others have described.

My ~/.profile by the way:

export "PATH=~/npm-global/bin:$PATH"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

Based on your error, I'd say you didn't set the permissions on that folder to have write access, assuming you followed the instructions correctly then it should work.

I assume, like the OP, you created the folder either a) with the wrong permissions and/or b) using root or sudo (sudo would just end up with root owning the folder in most cases).

Edit: the below commands will probably need to be executed using sudo. This is assigning ownership to that folder, which would already be correct if your user actually created the folder (as opposed to using sudo or root) and the second command will assign writable permissions to you, while only allowing read and execute to other user contexts, which should be the default umask used when your user creates a new folder.

Try this:

chown -R user:user /Users/TuzsNewMacBook/npm-global
chmod 0755 /Users/TuzsNewMacBook/npm-global

Clear the folder contents of /Users/TuzsNewMacBook/npm-global and try reinstalling.

As for your second question, I would say your first post answers that question: the packages aren't installed yet.

@manjunath1998
Copy link

sudo chown -R $USER ~/.npm try this

@manjunath1998
Copy link

sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local/lib/node_modules

and then reinstall expo-cli globaly works

its working

@ashishkamdar
Copy link
Author

ashishkamdar commented Sep 9, 2019 via email

@methodbox
Copy link

methodbox commented Oct 11, 2019

@prideaux
As I’ve repeatedly posted, multiple times in this same thread, chowning folders at a system level (/usr/local is considered system level in macOS although it’s commonly a user location in Linux) is a terrible idea and is NOT SAFE.

I’ve also repeatedly pointed out that moving the node_modules folder to your home directory safely and sanely resolves this issue.

Please see one of my many posts above (early in the thread, in particular) explaining how to do this using native npm commands.

You simply need to set the npm configuration path for node_modules to something in your home path.

EDIT: Most people are probably missing the first command here:

# Note that the target folder must exist
# when you run this command.
npm config set prefix '~/npm-global'

# Add to your profile:
export PATH=~/npm-global/bin:$PATH

And probably adding the export command to the wrong profile file - this is different depending on your shell.

Last, you need to either restart your terminal session (close all active windows) or use source [profile file name].

@prideaux
Copy link

@methodbox I agree and edited my post to remove the word safe, personally I incurred issues with the other solutions using macOS Catalina and needed to get back to work quick.

I will test other solutions on my main machine tomorrow and try and get it working again.

@prideaux
Copy link

prideaux commented Oct 11, 2019

@methodbox I believe you are 100% correct and the issue is that most are adding the export command to the wrong profile.

I found the following link using regarding the different profiles, zsh, bash etc

https://superuser.com/questions/187639/zsh-not-hitting-profile/187673#187673

@methodbox
Copy link

methodbox commented Oct 11, 2019

.bashrc or .bash-profile (these apply in user login context differently but *rc will generally do the trick) for bash, but they will not affect zsh; they are only read when the bash shell is loaded. This includes if you [incorrectly] configured your zsh shell to be loaded via a bash instruction; once you switch shells the profile is dropped.

For zsh I would stick to using .zshrc. .profile generally isn’t read for your normal terminal zsh session.

If you’re unclear which shell you’re actually using, just run echo $0 or echo $SHELL and your output with be the path of the shell binary currently running.

@prideaux
Copy link

@methodbox is 100% correct, I have gone through the steps successfully on 3 macs after carefully reading all the comments ▸ it is a solid and safe solution, thanks for all the help and advice!

A key part is knowing your profile/profile file you are going to create/edit, as detailed by @methodbox run echo $0 or echo $SHELL to get more info and read everything he wrote above carefully ;-)

Here are the exact steps I made on a clean install of macOS Catalina with zsh

  1. Install node (Download from https://nodejs.org)

  2. If npm-global directory does not already exist create it: mkdir ~/npm-global

  3. Set the target folder. npm config set prefix '~/npm-global'

  4. Add path to profile (on zsh): open -e .zshrc if it does not exist create using touch .zshrc

  5. Restart terminal or run source ~/.zshrc

Good luck!

@expo expo locked as resolved and limited conversation to collaborators Apr 6, 2020
@EvanBacon EvanBacon changed the title Mac OS : Error while running sudo nom install -g expo-cli --allow-root Mac OS : Error while running sudo npm install -g expo-cli --allow-root Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Installation The issue pertains to installing expo-cli OS: macOS The issue is occurring on macOS
Projects
None yet
Development

No branches or pull requests