Paulo Roberto Rosa
Paulo Roberto Rosa

Reputation: 3295

Can't run 'expo start' on a expo-react-native app, permission problem

Well, i see that already have many questions related to my problem on this site, but i also see that NONE of the solutions work for my specific case, because of that, i am opening that question, so it is not a duplicate.

Context (environment)

package.json

{
"main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo/vector-icons": "^9.0.0",
    "expo": "^32.0.0",
    "lodash.clonedeep": "^4.5.0",
    "native-base": "^2.10.0",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
    "react-native-credit-card-input": "https://github.com/itspauloroberto/react-native-credit-card-input.git",
    "react-native-password-strength-meter": "https://github.com/itspauloroberto/react-native-password-strength-meter.git",
    "react-native-responsive-screen": "^1.2.0",
    "react-native-scalable-image": "^0.5.0",
    "react-navigation": "^3.0.9",
    "react-redux": "^6.0.0",
    "redux": "^4.0.1",
    "redux-form": "^8.1.0",
    "redux-saga": "^0.16.2",
    "url-join": "^4.0.0",
    "vanilla-masker": "^1.2.0"
  },
  "devDependencies": {
    "babel-preset-expo": "^5.0.0"
  },
  "private": true
}

The Problem

My problem is when i try to run the following command expo start or npm start that is the same.

I HARDLY BELIEVE THAT IS A OS PROBLEM because last week i was using the same project on another os elementary-os and i had not any problems!

Then i get this error when i execute expo start or npm start:

Uncaught Error { [Error: EACCES: permission denied, open '/home/itspauloroberto/.expo/state.json.354451305']
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/home/itspauloroberto/.expo/state.json.354451305' }

How to reproduce it:

What i've tried

First of all, i have sure that this project/application runs ok, because i had another OS (elementaryOS) on last week and i was working on the project with no problems, also i have a team that works on it with no problems also.

Because of that i am creating this question, even if i see this error on many of the website none have my context.

Upvotes: 16

Views: 21100

Answers (4)

Rob Software
Rob Software

Reputation: 21

Often when you see an error like :

Uncaught Error Error: EACCES: permission denied, open '/Users/r/.expo/state.json.728296139'

you can try running the command again except with sudo in front of it.

For example, the error below:

expo init my-app
Uncaught Error Error: EACCES: permission denied, open '/Users/r/.expo/state.json.728296139'

Can be solved with:

$ sudo expo init my-app
Password:

Upvotes: 0

Shmuli Adelman
Shmuli Adelman

Reputation: 138

I had this issue because I had been working with cmd locally, and bash in an Ubuntu WSL2 sub-system.

I must have installed some packages from the ubuntu terminal, so besides for deleting a .expo file from my WSL home directory, I had to delete my node_modules file, and run npm install from my windows-cmd console.

Upvotes: 1

arslan
arslan

Reputation: 1144

uninstall expo first. then uninstall npm and reinstall npm and then expo

Upvotes: 0

Paulo Roberto Rosa
Paulo Roberto Rosa

Reputation: 3295

I found the problem!

The main reason was because, in some moment, i used sudo to install something related to expo, then expo created some files that belongs to the root user in another directory that was not on the project folder that i am working.

So it was because the initial files by expo on the very initial install of expo was installed using sudo apparently, because the files inside this directory: home/itspauloroberto/.expo and also the folder was owned by root (i checked it using la -ls command and saw root as the owner.) instead of my user itspauloroberto that was the main source of the error.

To get rid of this error, do the following steps:

  • navigate to the home/your_user/ directory.
  • delete the .expo folder using sudo rm -rf .expo (sudo needed because the folder owner is root)
  • run again expo using expo start

If you find any additional errors related to some directory or file, navigate to the file/directory that is on the error message and delete it. Because it should belong to root user also.

Upvotes: 44

Related Questions