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
相关产品推荐
相关产品推荐

