首页 > 解决方案 > 如何解决 MacOS 上 expo init 的 git 权限被拒绝问题?

问题描述

我在我的 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 项目。我已经正确设置了所有内容,但是这个问题只是坐在那里,花了一些时间才弄清楚试图更改某些文件夹等的访问权限。我该如何解决这个问题?

标签: gitmacosreact-nativeexpo

解决方案


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

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

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


推荐阅读