Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack build failing: "Can't import the named export 'Readable'" #617

Closed
mcuppi opened this issue Apr 27, 2019 · 2 comments
Closed

Webpack build failing: "Can't import the named export 'Readable'" #617

mcuppi opened this issue Apr 27, 2019 · 2 comments

Comments

@mcuppi
Copy link
Contributor

mcuppi commented Apr 27, 2019

Error
Importing the newest version of node-fetch (v2.4.0) is causing an error when building a project with webpack (4.30.0). This might be breaking many production environments. This is similar to #502.

ERROR in ./node_modules/node-fetch/lib/index.mjs 66:23-31
Can't import the named export 'Readable' from non EcmaScript module (only default export is available)

Cause
I believe the problem is because webpack doesn't resolve .mjs the same way node does. Importing node-fetch and running node v12.0.0 with experimental modules enabled runs without error. However, importing node-fetch using node v8.16.0 with experimental modules does result in the same error:

SyntaxError: The requested module does not provide an export named 'Readable'

Fix

I believe this can be fixed simply by changing the import in blob.js:

import { Readable } from 'stream';

to

import Stream from 'stream'
const Readable = Stream.Readable;

I've submitted a pull request for this fix: #618

@bitinn
Copy link
Collaborator

bitinn commented Apr 27, 2019 via email

@bitinn
Copy link
Collaborator

bitinn commented Apr 27, 2019

Fixed and published as 2.4.1 (npm show node-fetch version should verify this, not sure what's up with their website.)

@bitinn bitinn closed this as completed Apr 27, 2019
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

No branches or pull requests

2 participants