use-shopping-cart icon indicating copy to clipboard operation
use-shopping-cart copied to clipboard

Webpack 5 polyfill configuration issue

Open Nauman1971 opened this issue 3 years ago • 3 comments

Module not found: Error: Can't resolve 'crypto' with Webpack

Nauman1971 avatar Jul 05 '21 11:07 Nauman1971

Hi @Nauman1971, could you provide some more information about this error you're getting and what setup you're using?

Specifically, can you say what version of use-shopping-cart you're using?

andria-dev avatar Jul 05 '21 15:07 andria-dev

If you are using Webpack5 one way to fix it could be to add this on your Webpack config file:

resolve: { fallback: { crypto: false }, },

That's how I solved it.

Webpack also tells you which options you have:

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: { "crypto": require.resolve("crypto-browserify") }' - install 'crypto-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "crypto": false }

xmartinezpujol avatar Jul 05 '21 18:07 xmartinezpujol

Thank you for your reply. Yes i also solved this problem with the solution you provided

On Mon, 5 Jul 2021, 23:09 Xavier Martínez Pujol, @.***> wrote:

If you are using Webpack5 one way to fix it could be to add this on your Webpack config file:

resolve: { fallback: { crypto: false }, },

That's how I solved it.

Webpack also tells you which options you have:

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: { "crypto": require.resolve("crypto-browserify") }'
  • install 'crypto-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "crypto": false }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dayhaysoos/use-shopping-cart/issues/214#issuecomment-874265673, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIMITOVQP667WMVTOJ7B76LTWHYL7ANCNFSM472P4OAQ .

Nauman1971 avatar Jul 05 '21 19:07 Nauman1971