Windows 10,"expo build:android \"失败,并显示“错误:spawn/bin/cp ENOENT"; [英] Windows 10, 'expo build:android\ fails with "Error: spawn /bin/cp ENOENT"

查看:81
本文介绍了Windows 10,"expo build:android \"失败,并显示“错误:spawn/bin/cp ENOENT";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在解决了这个问题几个小时之后,我终于找到了解决方法.在此处发布消息,这样可能会在问题解决之前对某人有所帮助.

After several hours of fighting this problem, I finally found a workaround. Posting here so it might help someone until the issue is fixed.

运行 expo build:android expo publish 任务时,出现错误:

When running expo build:android or expo publish task finish with error:

The system cannot find the path specified.
[00:46:48] spawn /bin/cp ENOENT
[00:46:48] **Error: spawn /bin/cp ENOENT**
    at notFoundError (..\expo-cli\node_modules\cross-spawn\lib\enoent.js:11:11)
    at verifyENOENT (..s\expo-cli\node_modules\cross-spawn\lib\enoent.js:46:16)
    at ChildProcess.cp.emit (...s\expo-cli\node_modules\cross-spawn\lib\enoent.js:33:19)
     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
error Command failed with exit code 1.

与expo-cli问题有关:

Related to expo-cli issues:

运行 git bash 的建议解决方案不起作用,我还想避免在WSL上安装node和所有其他npm软件包.

Suggested solution to run git bash did not work, I also wanted to avoid installing node and all other npm packages on WSL.

Expo诊断程序

  Expo CLI 3.18.6 environment info:
    System:
      OS: Windows 10 10.0.18363
    Binaries:
      Node: 12.16.2 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD

推荐答案

之所以会出现此问题,是因为expo-cli代码假定/bin/cp 退出了(感谢 https://github.com/expo/expo-cli/issues/328#issuecomment-562809248).

The issue arises because the expo-cli code assumes that /bin/cp exits (found it thanks to https://github.com/expo/expo-cli/issues/328#issuecomment-562809248).

解决方案:

要使/bin/cp可用,您可以创建指向git bash的bin文件夹的符号链接-它包含必需的命令.确保在与您尝试编译的项目相同的驱动器中创建它(即,如果expo项目的路径为D:\ projects \ expo1,则在D:中创建符号链接)

To make the /bin/cp available you can create a symbolic link to the bin folder of the git bash - it contains the required commands. Make sure to create it in the same drive as the project you are trying to compile (i.e. if the path to your expo project is D:\projects\expo1, create the symbolic link in D:)

  1. 为Windows安装Git( https://gitforwindows.org/)
  2. 找到"Git for Windows"安装路径的路径.(例如C:\ Program Files \ Git)
  3. 以管理员身份打开cmd
  4. 转到expo项目所在的驱动器的根文件夹.(例如D:)
  5. 运行: mklink bin< git for Windows path> \ usr \ bin (例如mklink/d bin"C:\ Program Files \ Git \ usr \ bin")
  1. Install Git for windows (https://gitforwindows.org/)
  2. Find the path to the 'Git for windows' installation path. (e.g. C:\Program Files\Git)
  3. Open cmd as administrator
  4. Go to the root folder of the drive of which your expo project resides. (e.g. D:)
  5. Run: mklink bin <git for windows path>\usr\bin (e.g. mklink /d bin "C:\Program Files\Git\usr\bin")

希望它对外面的人有帮助,祝你好运!

Hope it helps to someone out there, Good luck!

这篇关于Windows 10,"expo build:android \"失败,并显示“错误:spawn/bin/cp ENOENT";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆