Skip to content

Improve error message when unrun is required and missing #1127

Description

@kevinoid

Clear and concise description of the problem

When I attempt to run tsdown in a project with tsdown.config.ts using Node.js v24.21.0 installed from the nodejs Debian package it reports Error: Failed to import module "unrun".

Initially I believed the problem was in the package I was attempting to build. Later I determined it was in tsdown. Even later I determined it was due to how tsdown handles the lack of TypeScript support in Node.js. (See Debian Bug 1151683 for why it's missing in Debian.)

Reproduction:

$ npm init -y
$ npm i -D tsdown
$ touch tsdown.config.ts
$ ./node_modules/.bin/tsdown
ℹ tsdown v0.23.7 powered by rolldown v1.3.1

 ERROR  Error: Failed to import module "unrun". Please ensure it is installed.
    at importWithError (file:///path/to/node_modules/tsdown/dist/style-BMCJFWa9.mjs:45:9)
    at async unrunImport (file:///path/to/node_modules/tsdown/dist/options-C2rtkmcY.mjs:600:20)
    at async iterateAsync (file:///path/to/node_modules/quansync/dist/src-C2Pm6gXo.js:58:28)
    at async iterateAsync (file:///path/to/node_modules/quansync/dist/src-C2Pm6gXo.js:58:28)
    at async iterateAsync (file:///path/to/node_modules/quansync/dist/src-C2Pm6gXo.js:58:28)
    at async loadConfigFile (file:///path/to/node_modules/tsdown/dist/options-C2rtkmcY.mjs:511:19)
    at async resolveConfig (file:///path/to/node_modules/tsdown/dist/build-S0sSJY-K.mjs:96:51)
    at async build$1 (file:///path/to/node_modules/tsdown/dist/build-S0sSJY-K.mjs:721:28)
    at async CAC.<anonymous> (file:///path/to/node_modules/tsdown/dist/run.mjs:21:2)
    at async runCLI (file:///path/to/node_modules/tsdown/dist/run.mjs:81:3)

Suggested solution

Perhaps it would be possible to catch the import error in unrunImport and throw an error with a more informative message, such as "unrun package must be installed when TypeScript support is not available in Node.js".

Alternative

If runtimes without TypeScript support are unsupported, print an error message informing the user that the platform is unsupported.

Additional context

No response

Validations

Activity

  1. added theissue type on Nov 9, 2026
  2. kevinoid commented on Nov 10, 2026

    @kevinoid
    Author

    Thanks @lazerg and @sxzz, #1129 looks perfect. I really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Fields

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions