我正在尝试启动我的第一个React Native项目(https://facebook.github.io/react-native/docs/getting-started.html)。它说在此页面上执行的第一个命令是
npm install -g expo-cli
将产生以下错误消息。
npm WARN checkPermissions Missing write access to /Users/~/.npm-packages/lib/node_modules/expo-cli/node_modules/ansi-escapes
.
.
.
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/~/.npm-packages/lib/node_modules/expo-cli/node_modules/ansi-escapes'
npm ERR! If you believe this might be a permissions issue, please double-check the permissions of the file and its containing directories, or try running the command again as root/Administrator (though this is not recommended).
所以我使用了sudo命令:
sudo npm install -g expo-cli
此命令成功通过,并输出一些警告(即跳过可选的依赖项):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-freebsd-ia32@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-freebsd-ia32):
.
.
.
+ expo-cli@2.7.0
updated 2 packages in 13.452s
然后,按照React Native页面的指示,我运行以下命令以使用expo:
expo init
这是结果:
zsh: command not found: expo
我用“ expo start”尝试了同样的事情,花了两个多小时来研究这个问题,但无济于事。非常感谢。
〜代表用户名
答案 0 :(得分:0)
小时后,研究和试验的,我发现了解决方案:
下载NVM https://github.com/creationix/nvm,并开始工作。对我来说,我必须创建一个文件(linux命令:触摸〜/ .bash_profile中)添加这些行的代码对源文件:
export NVM_DIR="~/.nvm"
source ~/.nvm/nvm.sh
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" #This loads nvm bash_completion
运行这些linux命令。我曾经不得不做sudo npm install -g expo-cli,它将安装expo-cli,但是我将无法使用expo-cli / expo命令:
nvm install node
nvm use --delete-prefix v11.9.0
npm install -g expo-cli
= d