ws package not working in react project because of webpack

Viewed 169

so I recently wanted to install ws but webpack suddenly threw out 17 errors.

So basically I:

  1. yarn added ws
  2. imported ws
  3. Typed in const connection = new ws.WebSocket("ws://127.0.0.1:6463/?v=1");
  4. compiled with errors

Errors:

enter image description here

This error is for multiple packages, basically adding a fallback "crypto... did nothing. Neither did installing crypto-browserify etc.

const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")

module.exports = {
    resolve: {
        alias: {
            path: require.resolve("path-browserify")
        }
    },
    target: 'node',
    plugins: [
        new NodePolyfillPlugin()
    ]
}

My webpack.config.js looks like this. I've already tried some things in there.

My question is. How do I get it working?

0 Answers
Related