TypeError:pna.nextTick不是在角度7中使用简单对等的函数

时间:2018-12-16 10:06:42

标签: angular angular6 webrtc simple-peer

我正在simple-peer中使用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)
    }
  }

Angular编译器发生此事件

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

然后抛出错误

  

enter image description here

当我忽略此event时,此错误消失了

注意:软件包版本与

相同
  1. simple-peer v9.1.2
  2. NPM v6.5.0
  3. Node v10.14.2

1 个答案:

答案 0 :(得分:0)

完全相同的问题已解决:

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

也可以安装:

npm i -S process-nextick-args