4

我刚刚react-native init在 Manjaro Linux 上创建了一个项目,并用 Android Studio 打开了它。然后我react-native start在终端上运行,然后在现有的模拟器上运行应用程序,该模拟器打开到红色屏幕,说明:

The development server returned response error code: 500
Metro Bundler has encountered an internal error, please check your terminal error output for more details

在我的终端窗口上,它给了我以下错误:

error: bundling failed: Error: EACCES: permission denied, open '/tmp/metro-cache/52/45f310fea946062ca0c3c6122dec6592f224f34ee755285a39fd0922f1d4c6739388c3'
    at Object.openSync (fs.js:443:3)
    at Object.writeFileSync (fs.js:1163:35)
    at FileStore.set (/home/user/ReactNativeProjects/albums/node_modules/metro-cache/src/stores/FileStore.js:43:8)
    at Cache.set (/home/user/ReactNativeProjects/albums/node_modules/metro-cache/src/Cache.js:96:31)
    at /home/user/ReactNativeProjects/albums/node_modules/metro/src/Bundler.js:287:13
    at Generator.next (<anonymous>)
    at step (/home/user/ReactNativeProjects/albums/node_modules/metro/src/Bundler.js:11:657)
    at /home/us/ReactNativeProjects/albums/node_modules/metro/src/Bundler.js:11:817
    at process._tickCallback (internal/process/next_tick.js:68:7)
 BUNDLE  [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

我检查了/tmp/metro-cache/52文件夹,但没有找到提到的文件。有谁知道可能导致此错误的原因?请注意,当我在我的物理设备上运行它时$ react-native run-android,我得到了同样的错误。

4

1 回答 1

12

我解决了这个问题。

sudo chmod 777 /tmp/metro-cache
cd /tmp/metro-cache
sudo chown -R $USER .

实际上,我不确定哪一个有效。大概chown就够了。

于 2020-05-03T20:38:23.307 回答