我试着用peerjs做一个小应用,但是当我尝试import Peer from "peerjs"的时候,我的代码崩溃了:
Uncaught ReferenceError: assignment to undeclared variable parcelRequire
在http://localhost:8080/_snowpack/pkg/peerjs.js:20
我在网上找不到任何东西。我不明白为什么snowpack使用parcel,因为我没有安装任何插件,我试图用Skypack导入Peerjs,但它是一样的。另一方面,当我测试导入另一个库时,在这里我使用canvas-confetti进行了测试,它可以工作。所以我不知道为什么Snowpack不喜欢Peerjs
发布于 2021-02-27 00:52:48
这是peerJs库的一个问题。
您可以看到导致此问题的代码行,您可能可以通过在导入here库之前设置window.parcelRequire来缓解此问题。考虑向peerJs的github提交一个问题。
发布于 2021-03-27 06:26:41
Atlassian https://bitbucket.org/atlassian/statuspage-status-widget/issues/3/uncaught-referenceerror-parcelrequire-is开发的状态微件使用的parcel-bundler https://github.com/parcel-bundler/parcel/issues/1401中也存在类似的错误
发布于 2021-11-05 08:06:17
您可以通过将esModuleInterop: true和allowSyntheticDefaultImports: true添加到tsconfig.json来修复此问题
https://stackoverflow.com/questions/66389575
复制相似问题