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

peerjs_min is not a constructor error when initialising Peer #761

Closed
arnu515 opened this issue Nov 27, 2020 · 7 comments
Closed

peerjs_min is not a constructor error when initialising Peer #761

arnu515 opened this issue Nov 27, 2020 · 7 comments

Comments

@arnu515
Copy link

arnu515 commented Nov 27, 2020

I'm using the Svelte framework with Rollup bundler (the default that comes with Svelte). I installed peerjs with:

npm i peerjs

And when I import it,

import Peer from "peerjs";
const peer = new Peer();

I get the error

parcelRequire is not defined

I found a temporary fix, i.e. to define it manually in index.html

<script>
     var parcelRequire;
</script>

But now, I'm getting a different error:

peerjs_min is not a constructor

I am using typescript, so I tried adding "esModuleInterlop": true to my tsconfig.json, but that did nothing.

Can you please help me? My rollup config is the default that came with Svelte. Many thanks!

@arnu515
Copy link
Author

arnu515 commented Nov 27, 2020

So I found a temporary fix, i.e. to use window.Peer instead of importing it. This is a really bad fix and I would appreciate it if anyone else would help me :)

@bosskabouter
Copy link

bosskabouter commented May 12, 2022

I was happily using peerjs in react until a few days ago.. now, with latest @1.4.1

In a clean npx create-react-app (npm 8.10, react 18.1.0)
npm i peerjs
import Peer from "peerjs";
new Peer();
throws Uncaught TypeError: peerjs__WEBPACK_IMPORTED_MODULE_4__ is not a constructor

Reverting back to1.3.2 resolves the issue for me for now:
npm r peerjs
rm -rf node_modules/
npm i peerjs@1.3.2

@arnu515
Copy link
Author

arnu515 commented May 12, 2022

Thanks for your work!

github-actions bot pushed a commit that referenced this issue May 12, 2022
## [1.4.2](v1.4.1...v1.4.2) (2022-05-12)

### Bug Fixes

* **bundler import:** enable module target ([b5beec4](b5beec4)), closes [#761](#761)
@jonasgloning
Copy link
Member

@arnu515, @bosskabouter
Patch is now availabe on npm, peerjs@1.4.2. Please try it and tell me if it solves your problem :)

@ckqbao
Copy link

ckqbao commented May 13, 2022

I have upgraded peerjs to version 1.4.2 then another issue hits me:

Uncaught TypeError: Cannot read properties of undefined (reading 'browser')
at class_1.push../node_modules/peerjs/dist/bundler.mjs.class_1.getBrowser (supports.ts:32:1)
at new Util (util.ts:51:1)
at Module../node_modules/peerjs/dist/bundler.mjs (util.ts:182:1)
at webpack_require (bootstrap:856:1)
at fn (bootstrap:150:1)

@jonasgloning
Copy link
Member

Hey @ckqbao. Oh no. I’ll look into it. Can you tell me how to reproduce this?
Maybe open a new issue, so others can find it.

@ckqbao
Copy link

ckqbao commented May 13, 2022

Hey @ckqbao. Oh no. I’ll look into it. Can you tell me how to reproduce this? Maybe open a new issue, so others can find it.

I just use peerjs normally and it works on version 1.3.2. I dont know if any one has the same issue

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

4 participants