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

Buffer not defined with Webpack 5 #1446

Closed
bojanvidanovic opened this issue Dec 21, 2021 · 5 comments
Closed

Buffer not defined with Webpack 5 #1446

bojanvidanovic opened this issue Dec 21, 2021 · 5 comments

Comments

@bojanvidanovic
Copy link

Incompatibility with Webpack 5, whereas it will throw an error "Buffer not defined".

@jcubic
Copy link
Contributor

jcubic commented Dec 21, 2021

Can you explain more? Maybe you can create reproducible example for the issue you're reporting?

Note that there are no active maintainer that can write code right now, the original author of the library is not actively working on the project (recently he added one PR). So if you will not willing to fix the issue yourself, it will probably be not fixed for a while, especially that you don't say what is the exact issue. Unless someone else that needed it will fix the issue for you.

@Sound1ab
Copy link

I ran into the same after updating CRA. The problem is that Webpack 5 no longer polyfills node packages. The packages need to be installed manually and added to the resolve.fallback object. More info in the webpack docs.

module.exports = {
  //...
  resolve: {
    fallback: {
      buffer: require.resolve('buffer'),
      process: require.resolve('process/browser'),
      stream: require.resolve('stream-browserify'),
    },
  },
};

You will also need to add these plugins:

const webpack = require('webpack');

module.exports = {
  // ...
  plugins: [
      new webpack.ProvidePlugin({
          Buffer: ['buffer', 'Buffer'],
      }),
      new webpack.ProvidePlugin({
          process: 'process/browser',
      }),
  ],
}

@seanpoulter
Copy link
Contributor

It seems like we can close this issue. Did that work for you @bojanvidanovic?

@jcubic
Copy link
Contributor

jcubic commented Apr 17, 2022

Maybe it's worth adding this to FAQ before closing.

@bojanvidanovic
Copy link
Author

It seems like we can close this issue. Did that work for you @bojanvidanovic?

Oh yes, that solves the issue. But as @jcubic mentioned, it should be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants