我刚刚在Manjaro Linux上使用react-native init
创建了一个项目,并使用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
在物理设备上运行它时,会遇到相同的错误。
答案 0 :(得分:3)
我解决了这个问题。
sudo chmod 777 /tmp/metro-cache
cd /tmp/metro-cache
sudo chown -R $USER .
实际上,我不确定哪一个有效。大概鲍恩就足够了。