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

Uncaught Error: Cannot find module 'stream' #1008

Closed
dabit1 opened this issue Nov 28, 2019 · 4 comments
Closed

Uncaught Error: Cannot find module 'stream' #1008

dabit1 opened this issue Nov 28, 2019 · 4 comments

Comments

@dabit1
Copy link

dabit1 commented Nov 28, 2019

Hi guys,

Inside of a service worker I import openpgp thorugh this.importScripts('/openpgp.min.js');. However when the service worker initiates it throws an error: Uncaught Error: Cannot find module 'stream'

  • Create-react-app
  • Chrome 78

Does anybody know why it happens?
Thanks

@chesnokovilya
Copy link
Contributor

chesnokovilya commented Dec 23, 2019

Could you provide code snippets? There is a worker implemented in the library, openpgp.worker.js has you tried to use it? It could be related to #1001, #896

@twiss
Copy link
Member

twiss commented Jan 2, 2020

OpenPGP.js only does require('stream') if it thinks that it's in Node.js. Could you, in the browser console of your Service Worker, type process and see whether that object exists? Maybe your build process is polyfilling it for some reason, making OpenPGP.js believe that it's in Node.js.

@gabidi
Copy link

gabidi commented Jan 2, 2020

might be related to #1007

@twiss
Copy link
Member

twiss commented Feb 27, 2021

Hi 👋 We've made a prerelease of v5: https://github.com/openpgpjs/openpgpjs/releases/tag/v5.0.0-0
We now have browser-specific and Node-specific builds, and the browser build no longer ever tries to require('stream'). You can grab a build here: http://unpkg.com/openpgp/dist/
Let me know if this works for you 😊

@twiss twiss closed this as completed Feb 27, 2021
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