Ncc: Error: Cannot find module 'asn1.js'

Created on 5 May 2020  Â·  6Comments  Â·  Source: vercel/ncc

Getting this error with asn1.js:

internal/modules/cjs/loader.js:800
    throw err;
    ^

Error: Cannot find module 'asn1.js'
Require stack:
- /home/runner/work/_actions/crazy-max/ghaction-import-gpg/v1/dist/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at o (/home/runner/work/_actions/crazy-max/ghaction-import-gpg/v1/dist/index.js:1892:200)
    at /home/runner/work/_actions/crazy-max/ghaction-import-gpg/v1/dist/index.js:1892:391
    at Object.<anonymous> (/home/runner/work/_actions/crazy-max/ghaction-import-gpg/v1/dist/index.js:32512:27)
    at Object.108.../../config (/home/runner/work/_actions/crazy-max/ghaction-import-gpg/v1/dist/index.js:33029:4)
    at o (/home/runner/work/_actions/crazy-max/ghaction-import-gpg/v1/dist/index.js:1892:340)
    at /home/runner/work/_actions/crazy-max/ghaction-import-gpg/v1/dist/index.js:1892:391 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/work/_actions/crazy-max/ghaction-import-gpg/v1/dist/index.js'
  ]
}

This module is required by openpgpjs and used in the GitHub Action ghaction-import-gpg.

Current workaround, add the following deps in node_modules:

  • asn1.js
  • bn.js
  • inherits
  • minimalistic-assert
  • safer-buffer

Looks like they are left out of the bundle by ncc.

Reproduce with:

git clone https://github.com/crazy-max/ghaction-import-gpg.git
cd ghaction-import-gpg/
yarn install
yarn run build
rm -rf node_modules/
node dist/index.js

All 6 comments

I am seeing this issue using also with my implementation of openpgpjs.

I found a workaround by forking the repo and updating their grunt script to include asn1.js

"openpgp": "https://github.com/vordimous/openpgpjs.git",

@vordimous
I think it's a smart idea ✨
Would you be planning to send a PR to https://github.com/openpgpjs/openpgpjs ?

opened a PR

I guess we will see if they want to change the way the lib is packaged.

I hope it's accepted or resolved in some other way.

There are some new workaround options from the openpgp dev on my PR

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tmtron picture tmtron  Â·  5Comments

guybedford picture guybedford  Â·  4Comments

stevage picture stevage  Â·  4Comments

benseitz picture benseitz  Â·  5Comments

GiladShoham picture GiladShoham  Â·  3Comments