Skip to content

fix: add --input-type=module to heredoc examples#22

Open
rubenflamshepherd wants to merge 1 commit intoSawyerHood:mainfrom
rubenflamshepherd:fix/heredoc-esm-input-type-1229
Open

fix: add --input-type=module to heredoc examples#22
rubenflamshepherd wants to merge 1 commit intoSawyerHood:mainfrom
rubenflamshepherd:fix/heredoc-esm-input-type-1229

Conversation

@rubenflamshepherd
Copy link

@rubenflamshepherd rubenflamshepherd commented Dec 29, 2025

Problem

The heredoc examples in SKILL.md fail with:

SyntaxError: Cannot use import statement outside a module

This happens because tsx reading from stdin doesn't know to treat the input as an ES module (no file extension to indicate module type).

I'll note the agent was able to find alternative approaches to this failure but it took a couple minutes and slowed down this part of the workflow.

Solution

Add --input-type=module flag to all npx tsx heredoc commands:

# Before
npx tsx <<'EOF'

# After
npx tsx --input-type=module <<'EOF'

Testing

Verified the fix works with Node.js v18.20.8 and tsx.

Changes

  • Updated heredoc example in 'Writing Scripts' section (line 61)
  • Updated heredoc example in 'Error Recovery' section (line 193)

- Update Writing Scripts section heredoc command
- Update Error Recovery section heredoc command

When tsx reads from stdin via heredoc, Node.js defaults to CommonJS mode
because there's no file extension to indicate module type. This causes
'SyntaxError: Cannot use import statement outside a module' when users
follow the documented heredoc pattern.

Adding --input-type=module explicitly tells Node.js to treat stdin as
an ES module, allowing import statements to work correctly.
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