Skip to content

Published dist/ uses extensionless imports — package unusable via Node ESM #2

@ExpertVagabond

Description

@ExpertVagabond

Problem

Every published version of @goatnetwork/agentkit (0.1.0, 0.1.1, 0.1.2) ships a dist/ whose .js files use extensionless relative imports. Node's ESM resolver requires explicit .js extensions, so the package fails to load via direct import:

```
$ node -e "import('@goatnetwork/agentkit').then(m => console.log(Object.keys(m)))"
Cannot find module '…/dist/core/index' imported from …/dist/index.js
```

Every subpath export has the same failure mode:

```
@goatnetwork/agentkit → can't resolve './core/index'
@goatnetwork/agentkit/core → can't resolve './errors/error'
@goatnetwork/agentkit/providers → can't resolve './action-provider'
@goatnetwork/agentkit/plugins → can't resolve './x402/index'
```

The examples in your repo work because they're run via tsx, which has a loader that auto-resolves extensionless paths. Pure Node ESM consumers (anyone doing `import { ActionProvider } from '@goatnetwork/agentkit'` in a published Node project) get `ERR_MODULE_NOT_FOUND`.

Repro

```bash
mkdir repro && cd repro
npm init -y
npm pkg set type=module
npm install @goatnetwork/agentkit
node -e "import('@goatnetwork/agentkit').then(m => console.log('OK', Object.keys(m).length))"

→ Cannot find module '…/dist/core/index'

```

Fix

Two options:

  1. Recommended: set `"moduleResolution": "NodeNext"` (or `"Node16"`) in `tsconfig.json`. TypeScript will then require `.js` suffixes in source imports, which compile cleanly to extensioned imports in the emitted JS. This also enforces the rule going forward.

  2. Quick patch: a post-build script that walks `dist/**/*.js` and rewrites `from '\./([^']+)'` → `from './$1.js'` (skipping already-extensioned imports and `node:` / package specifiers).

Impact

This blocks any Node ESM project from consuming the package — including any MCP server, any production agent runtime not using `tsx` in prod, and any user following the README's "Manual Installation" path.

Happy to send a PR with option 1 if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions