yarn全局安装expo-cli脚手架之后,命令不能执行:'expo' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

想用expo-cli搭建一个react-native应用,结果刚安装好脚手架就出错了,expo不能执行。

C:\Users\wanghongxuan>expo
'expo' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

解决办法:win10环境(任何 “不是内部或外部命令,也不是可运行的程序或批处理文件。” 都可以使用以下方法)
如果是使用npm安装依赖的话,输入指令:npm config list,找到prefix字段的值,是npm的路径,添加到环境变量就可以。如下图:
在这里插入图片描述
在这里,我使用的是yarn。使用yarn命令安装的话,输入指令:yarn global bin,找到bin文件的文件路径,如下:

C:\Users\wanghongxuan>yarn global bin
warning package.json: No license field
C:\Users\wanghongxuan\AppData\Local\Yarn\bin  //此处为文件路径

将bin文件的路径拷贝到Path环境变量中,保存。
Path环境变量:此电脑>鼠标右键:属性>高级系统设置>高级>环境变量>系统变量(S)>Path,

在这里插入图片描述
点击编辑按钮,新建环境变量,然后将bin文件路径复制到这里,保存。
在这里插入图片描述
注意:更改环境变量之后一定要重新开启命令行,然后执行命令,出现以下内容便是成功了。

C:\Users\wanghongxuan>expo

  Usage: expo [options] [command]

  Options:

    -V, --version                                       output the version number
    -o, --output [format]                               Output format. pretty (default), raw
    --non-interactive                                   Fail, if an interactive prompt would be required to continue. Enabled by default if stdin is not a TTY.
    -h, --help                                          output usage information

  Commands:

    android [options] [project-dir]                     Opens your app in Expo on a connected Android device
    build:ios|bi [options] [project-dir]                Build a standalone IPA for your project, signed and ready for submission to the Apple App Store.
    build:android|ba [options] [project-dir]            Build a standalone APK or App Bundle for your project, signed and ready for submission to the Google Play Store.
    build:web [options] [project-dir]                   Build a production bundle for your project, compressed and ready for deployment.
    build:status|bs [options] [project-dir]             Gets the status of a current (or most recently finished) build for your project.
    bundle-assets [options] [project-dir]               Bundles assets for a detached app. This command should be executed from xcode or gradle.
    ......
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值