Mac OS : Error while running sudo npm install -g expo-cli --allow-root #412
Comments
I am having the same issue. It appears to be related to node-gyp and looking for it in the wrong location. Still troubleshooting. |
I am seeing the same issue. Whats the resolution here ? |
Same issue here, any updates? |
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. |
@methodbox , I followed the option 2 from the link. But doesn't seem to fix the issue for me. |
@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. |
edit - wrong issue |
I get the same error on Ubuntu, so I don't think it's strictly related to MacOS:
My system:
|
i'm facing the same issue OS macOS 10.14.4 |
Same issue here. System info: OS: macOS 10.14.4 |
Any update? |
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
After using 8.11.2 the error disappeared. There is some problem while using |
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 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 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 |
@methodbox thanks I used option 1 and sudo is not even needed now. Thank you |
@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. |
@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. |
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 Maybe read above and find a better solution. Here's npm's own definition of what you're doing:
You're bypassing permissions checks and it's working because you're running as root, but that shouldn't be necessary. |
Change global directory works perfectly on Ubuntu too (see first comment by methodbox above) |
sudo chown -R $USER ~/.npm and then reinstall expo-cli globaly works |
Thank you @Tomerl101 The above trick is working for me. I am not sure is it a proper way to resolve this or not. |
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. |
And the (quick) answer stays : |
@methodbox, I tried that step two method and it didn't help at all:
Using My
|
Also, I used the infamous However:
What's wrong?? |
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 Try this: chown -R user:user /Users/TuzsNewMacBook/npm-global
chmod 0755 /Users/TuzsNewMacBook/npm-global Clear the folder contents of As for your second question, I would say your first post answers that question: the packages aren't installed yet. |
sudo chown -R $USER ~/.npm try this |
its working |
Tx.
Warm regards.
Ashish Kamdar
… On 09-Sep-2019, at 4:17 PM, manjunath1998 ***@***.***> wrote:
sudo chown -R $USER ~/.npm try this
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@prideaux 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 Last, you need to either restart your terminal session (close all active windows) or use |
@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. |
@methodbox I believe you are 100% correct and the issue is that most are adding the I found the following link using regarding the different profiles, zsh, bash etc https://superuser.com/questions/187639/zsh-not-hitting-profile/187673#187673 |
For zsh I would stick to using If you’re unclear which shell you’re actually using, just run |
@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 Here are the exact steps I made on a clean install of macOS Catalina with zsh
Good luck! |
👋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
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)
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
The text was updated successfully, but these errors were encountered: