Skip to content

fix: make CLI work without Bun when installed via npm#38

Open
djhenry wants to merge 1 commit into
Michaelliv:mainfrom
djhenry:fix/node-compatibility
Open

fix: make CLI work without Bun when installed via npm#38
djhenry wants to merge 1 commit into
Michaelliv:mainfrom
djhenry:fix/node-compatibility

Conversation

@djhenry

@djhenry djhenry commented May 26, 2026

Copy link
Copy Markdown

Summary

Fixes #37 — users on Fedora (and any system without Bun) got env: 'bun': No such file or directory immediately after npm install -g psst-cli.

Root causes:

  • bin in package.json pointed to ./src/main.ts which carries a #!/usr/bin/env bun shebang
  • Several source files used Bun-specific APIs (Bun.write, Bun.file, Bun.Glob, Bun.stdin) with no Node.js fallback

Changes:

  • bin now points to ./dist/main.js (already compiled by tsc in prepublishOnly)
  • Shebang changed to #!/usr/bin/env node
  • Bun.write()node:fs/promises writeFile (export.ts)
  • Bun.file().text()node:fs/promises readFile (import.ts, scan.ts)
  • Bun.Glob → recursive readdirSync walk (scan.ts)
  • Bun.stdin.stream() → Node.js readline interface (input.ts)
  • Added @types/node devDependency for TypeScript compilation

keychain.ts already had if (isBun) runtime guards with child_process fallbacks and needed no changes. The package continues to work under Bun as before.

Test plan

  • npm install -g psst-cli on a system without Bun, then psst --version succeeds
  • psst init --global creates vault successfully under Node.js
  • psst set, psst get, psst list, psst run work under Node.js
  • Existing Bun-based workflows unaffected (bun run src/main.ts still works)

🤖 Generated with Claude Code

The bin entry pointed to src/main.ts with a #!/usr/bin/env bun shebang,
so npm-installed users got 'env: bun: No such file or directory' on every
command. Fixes Michaelliv#37 on Michaelliv/psst.

Changes:
- bin now points to dist/main.js (compiled by tsc in prepublishOnly)
- Shebang changed to #!/usr/bin/env node
- Replaced Bun.write() with node:fs/promises writeFile (export.ts)
- Replaced Bun.file().text() with node:fs/promises readFile (import.ts, scan.ts)
- Replaced Bun.Glob with recursive readdirSync walk (scan.ts)
- Replaced Bun.stdin.stream() with Node.js readline interface (input.ts)
- Added @types/node devDependency for TypeScript compilation

keychain.ts already had if (isBun) guards with Node child_process fallbacks
and required no changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

env: ‘bun’: No such file or directory

1 participant