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

如何修复运行Deno程序时出现的Deno.setRaw未定义错误?

问题描述

尝试运行以下Deno命令:

deno run -A --unstable --no-check https://github.com/langwitch-tools/langwitch-deno/raw/main/src/configs/interactive.ts

出现错误:

error: Uncaught TypeError: Deno.setRaw is not a function
      (Deno.setRaw as setRaw)(
                             ^
    at Select.#readChar (https://deno.land/x/cliffy@v0.24.2/prompt/_generic_prompt.ts:299:30)
    at Select.#readKey (https://deno.land/x/cliffy@v0.24.2/prompt/_generic_prompt.ts:287:50)
    at Select.read (https://deno.land/x/cliffy@v0.24.2/prompt/_generic_prompt.ts:181:57)
    at Select.read (https://deno.land/x/cliffy@v0.24.2/prompt/_generic_list.ts:254:18)
    at Select.#execute (https://deno.land/x/cliffy@v0.24.2/prompt/_generic_prompt.ts:113:21)
    at async Select.prompt (https://deno.land/x/cliffy@v0.24.2/prompt/_generic_prompt.ts:92:14)
    at async https://raw.githubusercontent.com/langwitch-tools/langwitch-deno/main/src/configs/interactive.ts:28:12
解决方案

这个错误源于Deno.setRaw API与当前使用的Deno版本不兼容,依赖的cliffy@v0.24.2仍在调用该API,可按以下步骤解决:

  • 升级Deno到最新稳定版
    运行deno upgrade完成升级,新版Deno中Deno.setRaw已从Unstable转为稳定API,无需--unstable参数即可正常使用。

  • 调整运行命令
    升级后,去掉--unstable参数重新执行:

    deno run -A --no-check https://github.com/langwitch-tools/langwitch-deno/raw/main/src/configs/interactive.ts
    
  • 适配旧版Deno(无法升级时)
    如果无法升级Deno,可将脚本下载到本地,替换cliffy的导入路径为与当前Deno版本兼容的版本号(比如低版本cliffy适配旧版Deno,高版本适配新版)。

  • 确认终端环境
    确保在支持TTY的交互式终端(如本地bash/zsh)中运行命令,避免在非交互式环境执行。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 08:10:21