我想创建一个新的react native项目。最初,当我运行npm install -g expo-cli
时遇到了一个问题,我先安装了nvm,然后通过nvm安装了node和npm来解决了这个问题。当我运行expo init NewProject
时,出现此错误。
您能帮我解决吗?
Uncaught Error [Error: EACCES: permission denied, open
'/home/pgf/.expo/state.json.1309825572'] {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/home/pgf/.expo/state.json.1309825572'
}
我尝试了sudo expo init
;我得到了这个✖ Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app.
,它创建了一个项目。 Bur与expo start
一起运行项目时,出现此错误
Uncaught Error [Error: EACCES: permission denied, open '/home/pgf/.expo/state.json.2684774492'] {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/home/pgf/.expo/state.json.2684774492'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pgf/.npm/_logs/2020-05-29T19_37_07_602Z-debug.log
以及当我用sudo expo start
运行该错误时
Cannot determine which native SDK version your project uses because the module `expo` is not installed. Please install it with `yarn add expo` and try again.
您能帮我解决这个问题吗?
答案 0 :(得分:0)
对我来说,无需使用sudo来运行它,因为我遇到了权限错误。我不得不在不使用sudo的情况下全局重新安装expo-cli。之后,在您的项目目录中:
sudo rm -rf ~/.expo
npm run start