fix: resolve symlinked npm global bin path for standalone server.js#17
Conversation
When failproofai is installed globally via npm, the bin entry is a symlink. Bun can resolve import.meta.url to the symlink's directory rather than the real package directory, causing server.js to be looked up at the wrong path (e.g. ~/.next/standalone/server.js). Fix by wrapping fileURLToPath with realpathSync in both the bin entry point and scripts/launch.ts. The bin script also sets FAILPROOFAI_PACKAGE_ROOT early (before any dynamic imports) so launch.ts has a reliable fallback even if its own import.meta.url resolution is affected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe changes establish a more reliable package root resolution mechanism. The Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Summary
failproofaiis installed globally via npm and run, bun can resolveimport.meta.urlto the symlink's directory (e.g.~/.npm-global/bin/) rather than the real package directory, so the.next/standalone/server.jspath gets computed as~/.next/standalone/server.js(missing thelib/node_modules/failproofaiportion)fileURLToPath(import.meta.url)withrealpathSyncin bothscripts/launch.tsandbin/failproofai.mjsso symlinks are always resolved before path arithmeticbin/failproofai.mjssetsFAILPROOFAI_PACKAGE_ROOTearly (before any dynamic imports) solaunch.tscan use it as a primary sourceTest plan
npm packthe package and install it globally:npm install -g ./failproofai-*.tgzfailproofaifrom~— dashboard should start on port 8020 without theCannot find moduleerrorbun run test:run— existing tests pass🤖 Generated with Claude Code
Summary by CodeRabbit