node-fetch: The requested module does not provide an export named 'PassThrough'

Calling fetch gives me the following error

node_modules/node-fetch/lib/index.mjs:1
import Stream, { PassThrough } from 'stream';
                 ^^^^^^^^^^^
SyntaxError: The requested module does not provide an export named 'PassThrough'

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 14
  • Comments: 15

Commits related to this issue

Most upvoted comments

The published ESM in lib/index.mjs contains this line:

import Stream, { PassThrough } from 'stream'

Turns out, PassThrough is not a named export of stream in Node.js v8, but it is in v10:

// test.mjs
import { PassThrough } from 'stream'
node --experimental-modules test

In Node.js v8.12.0:

$ node --experimental-modules test
(node:32448) ExperimentalWarning: The ESM module loader is experimental.
SyntaxError: The requested module does not provide an export named 'PassThrough'
    at ModuleJob._instantiate (internal/loader/ModuleJob.js:85:17)
    at <anonymous>

In Node.js v10.11.0:

$ node --experimental-modules test
(node:32605) ExperimentalWarning: The ESM module loader is experimental.