You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装Yarn依赖时遭遇deasync模块spawn EINVAL错误求助

问题重现

执行yarn install时出现以下错误:

error C:\FOLDER\FOLDER\automatarium\node_modules\deasync: Command failed.
Exit code: 1
Command: node ./build.js
Arguments:
Directory: C:\FOLDER\FOLDER\automatarium\node_modules\deasync
Output:
node:internal/child_process:421
    throw new ErrnoException(err, 'spawn');
    ^

Error: spawn EINVAL
    at ChildProcess.spawn (node:internal/child_process:421:11)
    at Object.spawn (node:child_process:761:9)
    at build (C:\FOLDER\FOLDER\automatarium\node_modules\deasync\build.js:77:6)
    at Object.<anonymous> (C:\FOLDER\FOLDER\automatarium\node_modules\deasync\build.js:69:5)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/run_main:142:12)
    at node:internal/main/run_main_module:28:49 {
  errno: -4071,
  code: 'EINVAL',
  syscall: 'spawn'
}
解决方案

以下是针对Windows环境下该错误的可行修复步骤:

  • 匹配Node.js版本
    确认其他正常运行设备的Node.js版本,使用版本管理工具(如nvm-windows)切换到对应版本,再重新执行yarn install。Native模块对Node版本兼容性要求较高,版本不匹配是常见诱因。

  • 清理缓存与重装

    1. 清除yarn缓存:yarn cache clean
    2. 删除本地依赖文件:
      • Windows命令:rmdir /s /q node_modules && del yarn.lock
      • 或手动删除node_modules文件夹和yarn.lock文件
    3. 重新执行yarn install
  • 安装Windows构建工具
    deasync是C++编写的Native模块,需要Windows构建环境支持:

    1. 以管理员身份打开命令提示符
    2. 执行npm install -g windows-build-tools,等待工具安装完成(可能需要几分钟)
    3. 重启终端后重新执行yarn install
  • 手动编译deasync
    如果自动编译失败,尝试手动编译:

    1. 进入deasync目录:cd node_modules/deasync
    2. 执行node-gyp configure生成构建配置
    3. 执行node-gyp build完成编译
    4. 返回项目根目录继续完成安装

内容的提问来源于stack exchange,提问作者Excalibur 11

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 01:20:19