Openpgpjs: Error: Cannot find module 'openpgp'

Created on 4 Jul 2019  路  5Comments  路  Source: openpgpjs/openpgpjs

Error

Error: Cannot find module 'openpgp'
     at Function.Module._resolveFilename (module.js:548:15)
     at Function.Module._load (module.js:475:25)
     at Module.require (module.js:597:17)
     at require (internal/module.js:11:18)
     at Module._compile (module.js:653:30)
     at Object.Module._extensions..js (module.js:664:10)
     at Module.load (module.js:566:32)

Problem

Hello guys,
I'm using babel to transpile my code.
The problem is that openpgp doesn't work when the code is transpiled.

Workaround

I found a workaround. I've created a node_modules folder inside the build folder and I've copied these packages inside it:

  • node_modules/openpgp
  • node_modules/asn1.js
  • node_modules/bn.js
  • node_modules/minimalistic-assert

With this solution, I can use openpgp.

Can you check that.

Note

I've tested without babel and openpgp is working without any issues.
Unfortunately, I've need babel.

Information

OS: Linux & macOS
Node version: 8.16.0 - 10.16.0
Babel version: 6.26.0 (old one)

All 5 comments

Building openpgp.js using babel as part of a larger project is not really supported at the moment. If you can, I'd recommend including the build file directly using a script tag for now.

Thank you for the solution! I will use it while this issue is resolved.

I'd been facing to similar issue too.
if same cause, it can use another workaround maybe.

~https://github.com/vercel/ncc/issues/538#issuecomment-695008868~

This should be fixed by #1047 (in the upcoming v5 release).

Thank you very much !
You rock ! 馃殌

Was this page helpful?
0 / 5 - 0 ratings