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

Upgrading to 6.0.0.beta.7 emits "missing polyfills for node.js core modules" error #3112

Closed
PikachuEXE opened this issue Aug 17, 2021 · 5 comments

Comments

@PikachuEXE
Copy link

PikachuEXE commented Aug 17, 2021

Original Message:

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
	- install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "buffer": false }
resolve 'buffer' in 'project/path/node_modules/buffer-equal-constant-time'

This might or might not be issue of webpacker as I have no idea what requires the packages which require buffer or other core modules
I think this issue is worth mentioning in the upgrade guide anyway

Edit 1: For buffer, it's require chain looks like
webpack-dev-server > compression > safe-buffer > buffer

@Nittarab
Copy link

Can you try to upgrade to v6.0.0.rc.1?

Remember to run yarn upgrade and bundle update

@PikachuEXE
Copy link
Author

I got the same require chain
webpack-dev-server@npm:^3.11.2 > compression@npm:1.7.4 > safe-buffer@npm:5.1.2 > buffer

There are other packages besides compression having safe-buffer as dependency
I doubt this can be avoided

  • readable-stream@npm:2.3.7
  • randombytes@npm:2.1.0
  • express@npm:4.17.1
  • ecdsa-sig-formatter@npm:1.0.11
  • dns-packet@npm:1.3.4
  • convert-source-map@npm:1.8.0
  • content-disposition@npm:0.5.3
  • websocket-driver@npm:0.7.4
  • string_decoder@npm:1.1.1
  • string_decoder@npm:1.3.0
  • sha.js@npm:2.4.11

I also see both safe-buffer 5.1 & 5.2 in my yarn.lock

@Nittarab
Copy link

Btw this is not a webpacker issue, is caused by some of your dependency. Can you post the package.json?

@PikachuEXE
Copy link
Author

Well there is a binstub just for webpack-dev-server
I am saying the v6 upgrade guide should include references to fix/workaround for this common issue.

@PikachuEXE
Copy link
Author

If #2994 is fixed and webpack-dev-server v4 no longer contains dependency(s) using buffer, then this issue can be closed.

@dhh dhh closed this as completed Aug 25, 2021
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

3 participants