问题
I was having this annoying git problem with expo init command on my Mac.
MacBook-Pro:ReactNativeProjects SoftwareTheory$ sudo expo init proj2
Password:
? Choose a template: expo-template-blank
? Choose which workflow to use: managed
✔ Please enter a few initial configuration values.
Read more: https://docs.expo.io/versions/latest/workflow/configuration · 100% completed
[11:58:15] Extracting project files...
[11:58:15] Customizing project...
[11:58:15] Unable to initialize git repo. `git` not installed.
[11:58:15] Installing dependencies...
npm ERR! code 1
npm ERR! Command failed: /usr/local/bin/git clone --depth=1 -q -b expo-font-fix git://github.com/expo/vector-icons.git /Users/SoftwareTheory/.npm/_cacache/tmp/git-clone-3c497330
npm ERR! /Users/SoftwareTheory/.npm/_cacache/tmp/git-clone-3c497330/.git: Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/SoftwareTheory/.npm/_logs/2019-02-09T08_58_32_541Z-debug.log
[11:58:32] Process exited with non-zero code: 1
[11:58:32] Set EXPO_DEBUG=true in your env to view the stack trace.
I was just not able to start a basic ReactNative project. I had setup everything correctly but this problem was just sitting there and it took sometime to figure it out trying to change the access rights for some folders etc. How can I solve this?
回答1:
To solve this problem I did 2 things.
- Start a new terminal (iTerm in my case) and do a
sudo suimmediately. - Now run expo init command again with sudo:
sudo expo init my-proj
Then it worked. No errors. Hope this helps someone.
来源:https://stackoverflow.com/questions/54604946/how-to-solve-the-git-permission-denied-problem-with-expo-init-on-macos