[英]React native command not found
I am starting to install react native.我开始安装本机反应。 I had successfully installed homebrew, nodejs, npm.
我已经成功安装了自制软件、nodejs、npm。 but not able to install react native
但无法安装本机反应
First I had tried首先我试过
npm install -g react-native-cli
gives me write warning:给我写警告:
Missing write access to /Users/project/.npm-packages/lib/node_modules/react-native-cli
After that I had tried之后我尝试过
sudo npm install -g react-native-cli
/Users/project/.npm-packages/bin/react-native -> /Users/project/.npm-packages/lib/node_modules/react-native-cli/index.js /Users/project/.npm-packages/lib └── react-native-cli@1.0.0
Looks like install.看起来像安装。
After that I tried之后我尝试了
react-native init AwesomeProject
Error : react-native: command not found
What could be the problem可能是什么问题呢
First of all, you have to install react native globally首先,你必须全局安装react native
npm install -g react-native-cli
then it will show you the path for the react native like the following然后它会向您显示 react native 的路径,如下所示
/Users/{yourUser}/.npm-packages/bin/react-native -> /Users/{yourUser}/.npm-packages/lib/node_modules/react-native-cli/index.js
Then you have to set the default path from the above result and execute the following command然后你必须从上面的结果中设置默认路径并执行以下命令
export PATH="/Users/{yourUser}/.npm-packages/bin/:$PATH"
Then reload you session/env vairables然后重新加载会话/环境变量
source ~/.bash_profile
It will work like charm!它会像魅力一样工作!
Make sure that /usr/local/share/npm/bin
is in your PATH to use binaries installed with npm确保
/usr/local/share/npm/bin
在您的 PATH 中以使用通过 npm 安装的二进制文件
Add the following line to your ~/.bashrc将以下行添加到您的 ~/.bashrc
export PATH="/usr/local/share/npm/bin:$PATH"
Then reload your shell session and try that again然后重新加载您的 shell 会话并重试
sudo yarn global add expo-cli
sudo yarn global add react-native-cli
You must use sudo
here.您必须在这里使用
sudo
。
when you are using the latest version of node js and others related to react native当您使用最新版本的 node js 和其他与 react native 相关的
they updated to run react native app他们更新为运行反应原生应用程序
npx react-native run-android
npx react-native run-ios
npx react-native run-android
npx react-native run-ios
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.