2

I am using simple-peer in angular 7

async ngOnInit() {
    try {
      if (location.hash === '#init') {
        this.peer = new SimplePeer({
          initiator: location.hash === '#init'
        })
      }
      else {
        this.peer = new SimplePeer()
      }

      this.peer.on('signal', function (data) {
        console.log(JSON.stringify(data));
      })

      this.peer.on('data', (data) => {
        console.log('Received Data: ' + data)
      })
    } catch (error) {
      console.log(error)
    }
  }

When angular compiler comes on this event

this.peer.on('data', (data) => {
     console.log('Received Data: ' + data)
})

then it throws error

enter image description here

When I omit this event this error is gone

Note: Package versions are as

  1. simple-peer v9.1.2
  2. NPM v6.5.0
  3. Node v10.14.2
WasiF
  • 26,101
  • 16
  • 120
  • 128

1 Answers1

4

exact same issue solved:

npm i -S process, then add this to polyfill.ts:
import * as process from 'process';
window['process'] = process;

may also install:

npm i -S process-nextick-args