redis / node-redis

Redis Node.js client
https://redis.js.org/
MIT License
16.85k stars 1.87k forks source link

Polyfill issue with vueJs3 and Webpack5 #2024

Closed mathieumuller closed 2 years ago

mathieumuller commented 2 years ago

Hi everyone,

I am facing an issue with a fresh install of VueJs 3 with TypeScript. It seems Webpack 5 does not allow auto-polyfilling anymore and a lot of your dependencies cannot be resolved.

Is there any workaround for my case or is it just impossible for now to use with VueJs3?

Thanks in advance

Environment:

ERROR in ./node_modules/@node-redis/client/dist/lib/lua-script.js 8:17-34

Module not found: Error: Can't resolve 'crypto' in '/app/node_modules/@node-redis/client/dist/lib'

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 }
leibale commented 2 years ago

node-redis is not intended to run in the browser, what are you trying to do?

mathieumuller commented 2 years ago

node-redis is not intended to run in the browser, what are you trying to do?

Ok that's what I feared , I've read that a couple of times since. I just want to store the result of an API call, so I'm creating a redis client into my Vue component to get the cached data if exists or call my endpoint with axios. It seems I'm misusing something.