为什么重启 git bash 后运行 opencode 提示 post-install 没有运行

Ivan Lv6

每一次在 vscode 重启后重新开启 git bash, 都无法正确运行 opencode 命令, 会出现以下报错:

1
2
3
4
5
6
ASUS@LAPTOP-CN9D0PCU MINGW64 /d/Coding/projects/todo-canvas (main) $ opencode 
Error: opencode-ai's postinstall script was not run.

This occurs when using --ignore-scripts during installation, or when using a package manager like pnpm that does not run postinstall scripts by default.

To fix this, run the postinstall script manually: cd node_modules/opencode-ai && node postinstall.mjs Or reinstall opencode-ai without the --ignore-scripts flag.

在深入阅读了 opencode 命令执行的结果后, 我找到了原因. postinstall.mjs 这个文件唯一的作用就是将对应平台的 opencode 可执行二进制文件复制并放置到 node_modules/opencode-ai/bin/opencode.exe 中. 在执行 postinstall.mjs 脚本之前, 该目录中存放了一个占位符 opencode.exe 文件, 无法执行. 所以会产生报错.

但为什么执行之后又会被替代呢?

  • Title: 为什么重启 git bash 后运行 opencode 提示 post-install 没有运行
  • Author: Ivan
  • Created at : 2026-08-30 00:00:00
  • Updated at : 2026-10-23 18:02:31
  • Link: https://ivanfan-van.github.io/2026/08/30/note-3-growing-012/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page
为什么重启 git bash 后运行 opencode 提示 post-install 没有运行