Error: Cannot find module 'asn1.js'

Open
#538 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, node.js

Research direction

Run the reproduction in the ghaction-import-gpg repository through yarn run build, remove node_modules, and execute node dist/index.js. Inspect how ncc handles the openpgpjs dependencies listed in package.json and verify that the generated dist/index.js runs without manually installed modules.

Written by the indexing model from the issue text.

Description

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
Dominant language
JavaScript
Stars
9.8k
Forks
326
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel/ncc

All issues in vercel/ncc

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.