Skip to content

webpack 5 issue: process.nextTick is undefined #450

Closed

Description

@pbadenski

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.

Activity

  1. benjamingr commented on Oct 29, 2020

    @benjamingr
    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)

  2. markg85 commented on Oct 30, 2020

    @markg85

    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?

  3. mcollina commented on Oct 30, 2020

    @mcollina
    SponsorMember

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

  4. benjamingr commented on Oct 30, 2020

    @benjamingr
    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

  5. markg85 commented on Oct 30, 2020

    @markg85

    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?

  6. benjamingr commented on Oct 30, 2020

    @benjamingr
    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.

  7. markg85 commented on Oct 30, 2020

    @markg85

    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 :)

  8. kelly-tock commented on Dec 29, 2020

    @kelly-tock

    The solutions mentioned above are still not working for me.

    foliojs/pdfkit#1195

    For more information.

  9. kelly-tock commented on Jan 5, 2021

    @kelly-tock

    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

  10. kelly-tock commented on Jan 5, 2021

    @kelly-tock

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

  11. mcollina commented on May 23, 2022

    @mcollina
    SponsorMember

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions