Skip to content

fix: downgrade into-stream to 6.0.0 for CommonJS compatibility#220

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-error-requiring-into-stream
Draft

fix: downgrade into-stream to 6.0.0 for CommonJS compatibility#220
Copilot wants to merge 2 commits intomainfrom
copilot/fix-error-requiring-into-stream

Conversation

Copy link

Copilot AI commented Feb 19, 2026

into-stream 9.1.0+ is ESM-only. The pkg codebase compiles TypeScript to CommonJS, causing ERR_REQUIRE_ESM on startup.

Changes

  • Downgrade into-stream from ^9.1.0 to ^6.0.0 (last CommonJS version)
  • Update yarn.lock accordingly

The API is unchanged between versions for our usage (buffer-to-stream conversion).

Original prompt

This section details on the original issue you should resolve

<issue_title>Error requiring into-stream on pkg startup</issue_title>
<issue_description>### What version of pkg are you using?

6.14.0

What version of Node.js are you using?

22.4.1

What operating system are you using?

Ubuntu 22.04

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

node22-linux-x64, node22-win-x64

Describe the Bug

I have to run pkg on node v22.4.1. When I start pkg via npx, I immediately get this error:

$ npx pkg .
<...>/dct2/node_modules/@yao-pkg/pkg/lib-es5/producer.js:315
                    }
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module <...>/dct2/node_modules/@yao-pkg/pkg/node_modules/into-stream/index.js from <...>/dct2/node_modules/@yao-pkg/pkg/lib-es5/producer.js not supported.
Instead change the require of index.js in <...>/dct2/node_modules/@yao-pkg/pkg/lib-es5/producer.js to a dynamic import() which is available in all CommonJS modules.
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at Object.<anonymous> (<...>/dct2/node_modules/@yao-pkg/pkg/lib-es5/producer.js:11:39) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v22.4.1

Expected Behavior

pkg starts normally and can be used on node v22.4.1.

To Reproduce

  • Use node v22.4.1 (globally or via version manager)
  • Install @yao-pkg/pkg locally as dev dependency
  • Try npx pkg .

The error occurs regardless of having pkg config in package.json.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

The into-stream package version 9.1.0 is an ES Module (type: module),
which cannot be loaded with require() in CommonJS code. This caused
ERR_REQUIRE_ESM errors when running pkg.

Downgraded to into-stream@6.0.0, which is the last version that
supports CommonJS and can be used with require().

Fixes the issue where pkg would fail immediately on startup with
"Error [ERR_REQUIRE_ESM]: require() of ES Module" error.

Co-authored-by: robertsLando <11502495+robertsLando@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error requiring into-stream on pkg startup fix: downgrade into-stream to 6.0.0 for CommonJS compatibility Feb 19, 2026
Copilot AI requested a review from robertsLando February 19, 2026 15:35
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.

Error requiring into-stream on pkg startup

2 participants