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

Windows下Bun运行bun dev脚本报错:bunsh: No such file or directory

解决Windows下Bun运行脚本报错bunsh: No such file or directory
  • 指定脚本使用Windows原生shell
    修改package.json中的dev脚本,强制通过cmd或PowerShell执行命令:

    {
      "name": "app",
      "version": "1.0.50",
      "scripts": {
        "dev": "cmd /c bun --watch run src/index.ts"
      },
      "module": "src/index.js"
    }
    

    若偏好PowerShell,可改成:

    {
      "name": "app",
      "version": "1.0.50",
      "scripts": {
        "dev": "powershell -Command \"bun --watch run src/index.ts\""
      },
      "module": "src/index.js"
    }
    
  • 全局配置Bun默认使用Windows shell
    在终端执行以下命令,将Bun的默认shell设置为cmd或PowerShell:

    bun config set shell "cmd.exe"
    # 或者
    bun config set shell "powershell.exe"
    

    配置完成后直接运行bun run dev即可。

  • 使用Bun绝对路径执行脚本
    先在终端输入where bun获取Bun的安装路径,随后在package.json中替换为绝对路径:

    {
      "name": "app",
      "version": "1.0.50",
      "scripts": {
        "dev": "C:\\Users\\你的用户名\\AppData\\Roaming\\npm\\bun.exe --watch run src/index.ts"
      },
      "module": "src/index.js"
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 01:51:02