我正在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)
})
然后抛出错误
当我忽略此event
时,此错误消失了
注意:软件包版本与
相同simple-peer v9.1.2
NPM v6.5.0
Node v10.14.2
答案 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