Skip to content

webpack 5 issue: process.nextTick is undefined #450

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

Closed
pbadenski opened this issue Oct 29, 2020 · 11 comments
Closed

webpack 5 issue: process.nextTick is undefined #450

pbadenski opened this issue Oct 29, 2020 · 11 comments

Comments

@pbadenski
Copy link

Getting an error with webpack 5 since process.nextTick isn't being polyfilled automatically.

_stream_writable.js?5bc2:459 Uncaught ReferenceError: process is not defined
    at onwrite (_stream_writable.js?5bc2:459)
    at WritableState.onwrite (_stream_writable.js?5bc2:160)
    at module.exports.ClientRequest._write (request.js?925e:262)
    at doWrite (_stream_writable.js?5bc2:409)
    at writeOrBuffer (_stream_writable.js?5bc2:398)
    at module.exports.Writable.write (_stream_writable.js?5bc2:307)

Would the answer be to polyfill this manually? If yes - might be useful to add to documentation.

@benjamingr
Copy link
Member

Would the answer be to polyfill this manually? If yes - might be useful to add to documentation.

In the meantime yes. Though I think readable-stream can probably use enqueueMicrotask (that is available in browsers as well)

@markg85
Copy link

markg85 commented Oct 30, 2020

I have this very same issue!
After a few hours of debugging, and using this library because it claims to be browser compatible, i ended up here about to report a bug. This library uses process.nextTick which you don't have in a browser.

I am surprised to find that - when doing git blame - process.nextTick is already used for at least a year! How come nobody ever had an issue with it thus far?

Note, i too am using webpack 5. If anyone has an intermediate solution, i'm all ears!
How do you manually and properly polyfill it?

@mcollina
Copy link
Member

This library does not support Webpack 5. It runs in browsers with browserify and Webpack 4.

@benjamingr
Copy link
Member

@markg85 fwiw you can jut tell Webpack 5 to polyfill process APIs - it's just setting up an alias. I can't find official docs but here: https://medium.com/@sanchit3b/how-to-polyfill-node-core-modules-in-webpack-5-905c1f5504a0

@markg85
Copy link

markg85 commented Oct 30, 2020

This library does not support Webpack 5. It runs in browsers with browserify and Webpack 4.

I see. After posting my comment i found #435 which explains why it doesn't work.
I'm beginning to build up a big hatred against webpack :P I don't like it, i don't want to use it.. It just seemed to be the most logical thing to use when making something in node.js and wanting to run it in the browser. In this specific case i want to run a libp2p experiment in the browser.

While i do get the webpack point of view of not supporting node object injections like process, it is a sore pain in the *** that the package world isn't ready yet for their (idealistic?) views.

To be honest, it's probably time for me to look for an alternative to webpack. I don't want or need to be looking for solutions for hours. I just want nodejs app compile to website compatible and be done with it. Webpack used to be an ok-ish fit for that. Not anymore it seems.

@markg85 fwiw you can jut tell Webpack 5 to polyfill process APIs - it's just setting up an alias. I can't find official docs but here: https://medium.com/@sanchit3b/how-to-polyfill-node-core-modules-in-webpack-5-905c1f5504a0

I found that one too. I find these examples to be severely biased towards people who know all the ins and outs of webpack already and know enough by reading one line. I'm apparently not one of those. Do you have an actual example of what i should be putting in the webpack config file and/or package.json?

@benjamingr
Copy link
Member

Do you have an actual example of what i should be putting in the webpack config file and/or package.json?

No since I haven't updated to webpack 5 myself. After the webpack 3->4 upgrade fiasco I've resigned to wait 6 months before attempting to upgrade. I'd just use webpack 4 and wait if I were you.

@markg85
Copy link

markg85 commented Oct 30, 2020

Do you have an actual example of what i should be putting in the webpack config file and/or package.json?

No since I haven't updated to webpack 5 myself. After the webpack 3->4 upgrade fiasco I've resigned to wait 6 months before attempting to upgrade. I'd just use webpack 4 and wait if I were you.

So parcel works like a charm without any issue at all!
Which makes me wonder, why the hell do i keep torturing myself with webpack if there is something (way) better out there.

Guess i'm a parcel user now :)

@kelly-tock
Copy link

The solutions mentioned above are still not working for me.

foliojs/pdfkit#1195

For more information.

@kelly-tock
Copy link

also, just for anyone that ends up here, here's a list from webpack of the modules that are used in v4, was more clear to me at least than the medium article:
https://github.com/webpack/node-libs-browser

@kelly-tock
Copy link

also, some success with process polyfill for pdfkit:
foliojs/pdfkit#1195

@mcollina
Copy link
Member

Will be fixed in v4.0.0

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

5 participants