peers / peerjs

Simple peer-to-peer with WebRTC.
https://peerjs.com
MIT License
12.48k stars 1.43k forks source link

peerjs_WEBPACK_IMPORTED_MODULE_2_ #559

Closed lvargass closed 2 years ago

lvargass commented 5 years ago

good afternoon,

I am working on an application in ionic 4 with angular but I am having this error;

ERROR TypeError: peerjs_WEBPACK_IMPORTED_MODULE2 is not a constructor.

when I am trying to connect to the peerjs server, eg;

*import { Component } from '@angular/core'; import { PeerJSOption } from 'peerjs'; import as Peer from 'peerjs';

@Component({ selector: 'app-tab1', templateUrl: 'tab1.page.html', styleUrls: ['tab1.page.scss'] }) export class Tab1Page { protected peer: Peer;

constructor() { const coon: PeerJSOption = { host: 'localhost', port: 9000, path: '/myapp' }; this.peer = new Peer('person3', coon); console.log(this.peer); } }**

dependences "dependencies": { "@angular/common": "^7.2.2", "@angular/core": "^7.2.2", "@angular/forms": "^7.2.2", "@angular/http": "^7.2.2", "@angular/platform-browser": "^7.2.2", "@angular/platform-browser-dynamic": "^7.2.2", "@angular/router": "^7.2.2", "@ionic-native/core": "^5.0.0", "@ionic-native/splash-screen": "^5.0.0", "@ionic-native/status-bar": "^5.0.0", "@ionic/angular": "^4.1.0", "buffer": "^5.2.1", "core-js": "^2.5.4", "peerjs": "^1.0.2", "rxjs": "~6.5.1", "simple-peer": "^9.4.0", "tslib": "^1.9.0", "zone.js": "~0.8.29" },

afrokick commented 5 years ago

Did you try solution from this issue? https://github.com/peers/peerjs/issues/533

lvargass commented 5 years ago

No, I still have the same problem.

On Wed, Aug 21, 2019 at 11:20 AM afrokick notifications@github.com wrote:

Did you try solution from this issue? #533 https://github.com/peers/peerjs/issues/533

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/peers/peerjs/issues/559?email_source=notifications&email_token=ACR6XUSKDKRTRJHFMVCCCRLQFVMKRA5CNFSM4IG5W4HKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD42A36Y#issuecomment-523505147, or mute the thread https://github.com/notifications/unsubscribe-auth/ACR6XUT4F5U27N4SC5EPWWTQFVMKRANCNFSM4IG5W4HA .

dunkfordyce commented 4 years ago

Your import line should be import Peer from "peerjs"

ChrisAcrobat commented 3 years ago

I get a similar issue. ERROR TypeError: peerjs__WEBPACK_IMPORTED_MODULE_0__ is not a constructor @dunkfordyce: That gives me a compile error.

ChrisAcrobat commented 3 years ago

I solved it.

  1. Add "./node_modules/peerjs/dist/peerjs.min.js" to projects.THE_PROJECT.architect.build.options.scripts.
  2. In the .ts file add below import: declare var Peer:any;
  3. Exit and restart ng serve! I guess this is what have been missing all along.
afrokick commented 2 years ago

Should be fixed in peerjs@beta.0