简体   繁体   中英

React Native running in emulator gives bundling failed: permission denied error

I have just created a project with react-native init on Manjaro Linux and opened it with Android Studio . I then ran react-native start on a terminal and then ran the app on an existing emulator which opened to a red screen stating:

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

On my terminal window, it gave me the following error:

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.

I checked the /tmp/metro-cache/52 folder but did not find the mentioned file. Does anybody know what may be causing this error? Note that when I run it on my physical device with $ react-native run-android , I get the same error.

I solved the problem.

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

Actually, I am not sure which one is worked. Probably chown is enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM