Skip to content

fix: global install fails with ERR_MODULE_NOT_FOUND for workspace packages#336

Merged
khaliqgant merged 1 commit intomainfrom
hotfix/global-install-daemon-missing
Jan 28, 2026
Merged

fix: global install fails with ERR_MODULE_NOT_FOUND for workspace packages#336
khaliqgant merged 1 commit intomainfrom
hotfix/global-install-daemon-missing

Conversation

@khaliqgant
Copy link
Collaborator

@khaliqgant khaliqgant commented Jan 28, 2026

Summary

  • Fix verify-publish workflow to build packages before npm pack on PRs
  • Add workspace package symlink setup in postinstall.js for global installs

Problem

When globally installing agent-relay, the CLI fails with:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@agent-relay/daemon' imported from dist/src/cli/index.js

This happens because:

  1. The verify-publish workflow was running npm ci --ignore-scripts then npm pack without building
  2. Without building, the packages/*/dist/ folders don't exist
  3. When globally installed, Node.js can't resolve the workspace package imports

Solution

  1. Remove --ignore-scripts from npm ci in verify-publish workflow
  2. Add explicit npm run build step before npm pack on PRs
  3. Add setupWorkspacePackageLinks() in postinstall.js as a fallback to create symlinks from node_modules/@agent-relay/* to packages/* for bundled/global installs

Test plan

  • PR workflow verify-publish passes
  • Global install test: npm install -g agent-relay then agent-relay --version
  • npx test: npx agent-relay --version

🤖 Generated with Claude Code


Open with Devin

…flow

The verify-publish workflow was packing without building, causing
global installs to fail with ERR_MODULE_NOT_FOUND for workspace packages.

Changes:
- Remove --ignore-scripts from npm ci to allow postinstall to run
- Add explicit build step before npm pack in PR verification
- Add setupWorkspacePackageLinks() to postinstall.js as fallback for
  global installs where bundledDependencies may not properly resolve
  workspace symlinks

Fixes global install error: Cannot find package '@agent-relay/daemon'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@khaliqgant khaliqgant merged commit d377b98 into main Jan 28, 2026
33 of 37 checks passed
@khaliqgant khaliqgant deleted the hotfix/global-install-daemon-missing branch January 28, 2026 14:37
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 verify job doesn't use local tarball on PRs, testing npm package instead of PR changes

The verify job's Get package spec step (lines 61-73) doesn't check for pull_request event and always sets SPEC="agent-relay" (the npm package), ignoring the local tarball that was just built.

Click to expand

Problem

In the verify job, the workflow:

  1. Builds and packs the local code with npm pack (line 54)
  2. But then the Get package spec step only checks inputs.version and defaults to SPEC="agent-relay" from npm

Compare with the verify-macos job at .github/workflows/verify-publish.yml:346-361 which correctly handles PRs:

if [ "${{ github.event_name }}" = "pull_request" ]; then
  SPEC="$(pwd)/$(ls agent-relay-*.tgz | head -1)"
else
  ...
fi

Impact

On PRs, the verify job tests the published npm package instead of the PR's changes. This means:

  • The PR's fix for global install (setupWorkspacePackageLinks) is never tested
  • The workflow passes even if the PR introduces bugs
  • False confidence that PR changes work correctly

Expected vs Actual

  • Expected: On PRs, test the local tarball built from PR code
  • Actual: On PRs, test the existing npm package agent-relay@latest

(Refers to lines 61-73)

Recommendation: Add a check for pull_request event similar to the verify-macos job:

if [ "${{ github.event_name }}" = "pull_request" ]; then
  SPEC="$(pwd)/$(ls agent-relay-*.tgz | head -1)"
elif [ -z "$VERSION_INPUT" ] || [ "$VERSION_INPUT" = "latest" ]; then
  ...
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant