昨天需要查看项目的react-native版本号,于是执行
react-native -v
结果显示command not found,于是一顿搜,搜到了同样一顿搜之后解决并且分享的大佬,非常感谢!
解决方法:
把npm安装位置写入配置文件
1、全局执行
sudo npm i -g react-native-cli
由于昨天没有截图,借用了大佬的

2、打开配置文件
open ~/.bash_profile
3、写入配置文件

4、保存之后
source ~/.bash_profile
5、查看是否配置成功,显示了加上去的地址就是成功了
echo $PATH
6、注意:查询react-native -v的时候需要在项目的根目录中执行,结果查询成功!

感谢:
https://blog.csdn.net/F_G_Victory/article/details/93741059
网友评论