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

simple-peer.js?v=eb7dd428:571 Uncaught (in promise) Error: Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11 at oldBrowser (simple-peer.js?v=eb7dd428:571:13) at new _Peer (simple-peer.js?v=eb7dd428:5966:20) at prepareNewPeerConnection (webRTCHandler.js:59:29) at Socket2.<anonymous> (socketConnection.js:58:5) at Emitter.emit (socket__io-client.js?v=77d8b3f1:427:21) at Socket2.emitEvent (socket__io-client.js?v=77d8b3f1:2731:16) at Socket2.onevent (socket__io-client.js?v=77d8b3f1:2719:12) at Socket2.onpacket (socket__io-client.js?v=77d8b3f1:2690:14) at Emitter.emit (socket__io-client.js?v=77d8b3f1:427:21) at socket__io-client.js?v=77d8b3f1:3287:12 i m getting this error while using react vite please can anybody solve this error i m stuck #932

Open
amaann2 opened this issue Mar 24, 2024 · 5 comments

Comments

@amaann2
Copy link

amaann2 commented Mar 24, 2024

What version of this package are you using?

What operating system, Node.js, and npm version?

What happened?

What did you expect to happen?

Are you willing to submit a pull request to fix this bug?

@MohamedAmineNasri
Copy link

@amaann2 i'm facing the same issue

@MohamedAmineNasri
Copy link

it worked for me using this import import Peer from 'simple-peer/simplepeer.min.js'
instead of this import Peer from 'simple-peer';
and without using global in defineConfig in vite

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
});

@codewithdripzy
Copy link

codewithdripzy commented Apr 17, 2024

found the solution to this, just in your vite.config.ts or vite.cofig.js comment out global: {}, worked for me, your vite.config.ts file should look like this

import react from '@vitejs/plugin-react'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react(), nodePolyfills({
    exclude : []
  }),
],
  define: {
    // global: {}
  },
})

@garnsworthy
Copy link

import { nodePolyfills } from 'vite-plugin-node-polyfills'
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";

export default defineConfig({
plugins: [
react(),
nodePolyfills({include:['crypto', 'buffer', 'stream', 'util']}),
viteCommonjs(),
],

I am using node-bignumber to calculate an RSA encrypt value, I have to require it instead of import it, that is the viteCommonjs. Then I have to polyfill crypto and buffer for it, that is the polyfills.

Then commenting out global fixed the issue with randomNumber missing for me for some reason. So thanks!

@FarhanDevelopeir
Copy link

@codewithdripzy thanks brother it's working

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

5 participants