[GH-ISSUE #488] ERR_MODULE_NOT_FOUND on Windows - tsdown.config.ts external regex incorrectly excludes local modules #268

Closed
opened 2026-06-05 17:21:22 -04:00 by yindo · 1 comment
Owner

Originally created by @sukhmanghotraa on GitHub (Apr 26, 2026).
Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/488

Summary
When building the "deepagents" library on windows, "dist/index.js" imports local modules with .ts extensions (e.g. ./agent.ts) instead of bundling them. This causes an immediate ERR_MODULE_NOT_FOUND crash at runtime.

Steps to Reproduce

  1. Clone the repo on a Windows machine
  2. cd libs/deepagents && pnpm run build
  3. Inspect [dist/index.js] - it contains raw .ts imports: import { createDeepAgent } from "./agent.ts"
  4. Run any example: pnpm dlx @langchain/langgraph-cli dev

Error

Error [ERR_MODULE_NOT_FOUND]: Cannot find module
  'C:\...\deepagentsjs\libs\deepagents\dist\agent.ts'
  imported from C:\...\deepagentsjs\libs\deepagents\dist\index.js

Root cause
In libs/deepagents/tsdown.config.ts:

const external = [/^[^./]/];  // intended to match npm packages only

On Unix absolute paths start with / so the regex correctly excludes them. On Windows absolute paths start with a drive letter (e.g. C:\...), which also doesn't start with . or / - so rolldown matches them as external, excludes them from the bundle, and leaves raw .ts references in the output.

Fix

// Before
const external = [/^[^./]/];

// After
const external = (id: string) =>
  !id.startsWith(".") && !id.startsWith("/") && !/^[A-Za-z]:[\\/]/.test(id);
Originally created by @sukhmanghotraa on GitHub (Apr 26, 2026). Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/488 **Summary** When building the "deepagents" library on windows, "dist/index.js" imports local modules with .ts extensions (e.g. ./agent.ts) instead of bundling them. This causes an immediate ERR_MODULE_NOT_FOUND crash at runtime. **Steps to Reproduce** 1. Clone the repo on a Windows machine 2. `cd libs/deepagents && pnpm run build` 3. Inspect [dist/index.js] - it contains raw .ts imports: `import { createDeepAgent } from "./agent.ts"` 4. Run any example: `pnpm dlx @langchain/langgraph-cli dev` **Error** ``` Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\...\deepagentsjs\libs\deepagents\dist\agent.ts' imported from C:\...\deepagentsjs\libs\deepagents\dist\index.js ``` **Root cause** In `libs/deepagents/tsdown.config.ts:` ``` const external = [/^[^./]/]; // intended to match npm packages only ``` On Unix absolute paths start with `/` so the regex correctly excludes them. On Windows absolute paths start with a drive letter `(e.g. C:\...)`, which also doesn't start with `.` or `/` - so rolldown matches them as external, excludes them from the bundle, and leaves raw .ts references in the output. **Fix** ``` // Before const external = [/^[^./]/]; // After const external = (id: string) => !id.startsWith(".") && !id.startsWith("/") && !/^[A-Za-z]:[\\/]/.test(id); ```
yindo closed this issue 2026-06-05 17:21:22 -04:00
Author
Owner

@hntrl commented on GitHub (Apr 27, 2026):

Fixed in #489

<!-- gh-comment-id:4330701027 --> @hntrl commented on GitHub (Apr 27, 2026): Fixed in #489
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#268