如何在MacOS上使用expo init解决git权限被拒绝的问题?

时间:2019-02-09 09:30:48

标签: git macos react-native expo

我在Mac上的expo init命令中遇到了这个令人讨厌的git问题。

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.

我只是无法启动一个基本的ReactNative项目。我已经正确设置了所有内容,但是这个问题就坐在那儿,花了一些时间才弄清楚试图更改某些文件夹等的访问权限。我该如何解决呢?

1 个答案:

答案 0 :(得分:1)

为解决这个问题,我做了两件事。

  1. 启动一个新终端(在我的情况下为iTerm)并立即执行sudo su
  2. 现在使用sudo再次运行expo init命令:sudo expo init my-proj

然后它起作用了。没有错误。希望这对某人有帮助。