Skip to content

fix(js): resolve daemon path for global npm symlinks - #2

Open
kuopenx-agent wants to merge 2 commits into
Bin-Huang:mainfrom
kuopenx-agent:fix/js-daemon-symlink-path
Open

fix(js): resolve daemon path for global npm symlinks#2
kuopenx-agent wants to merge 2 commits into
Bin-Huang:mainfrom
kuopenx-agent:fix/js-daemon-symlink-path

Conversation

@kuopenx-agent

@kuopenx-agent kuopenx-agent commented Mar 11, 2026

Copy link
Copy Markdown

Summary

Fix daemon startup when camoufox-cli is installed globally via npm install -g or used via npm link.

When installed globally, the camoufox-cli executable is typically a symlink to dist/cli.js. The previous implementation derived daemon.js from import.meta.url directly, which can resolve relative to the symlink location instead of the real dist/ directory. Also, the CLI entrypoint check only matched paths ending in /cli.js or /cli.ts, so a symlinked executable like .../bin/camoufox-cli would not call main() at all.

Together, these issues can cause the daemon to fail to start or the CLI to silently exit with no output.

Closes #1.

Changes

  • resolve the CLI module path with fs.realpathSync(fileURLToPath(import.meta.url))
  • derive daemon.js from the resolved real path
  • detect direct execution by comparing the real path of process.argv[1] against the module path
  • add unit tests covering the symlinked executable case for both daemon path resolution and direct-run detection
  • fix the README architecture text to say Daemon (Node.js) instead of Daemon (Python)

Validation

  • npm --prefix js test
  • npm --prefix js run build

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.

Bug: Daemon fails to start after npm install -g due to symlink path resolution

2 participants