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

fix: cjs module without file extension #27904

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

rnbguy
Copy link
Contributor

@rnbguy rnbguy commented Feb 1, 2025

closes #27172

Fixes an edge scenario when yargs/17.7.2/yargs doesn't have any extension.

$ [email protected] run -A npm:@informalsystems/quint --version
error: Uncaught (in promise) ReferenceError: require is not defined
    at file:///home/ranadeep/.cache/deno/npm/registry.npmjs.org/yargs/17.7.2/yargs:3:69
    at loadESMFromCJS (node:module:775:21)
    at Module._compile (node:module:720:12)
    at loadMaybeCjs (node:module:768:10)
    at Object.Module._extensions..js (node:module:759:12)
    at Module.load (node:module:660:32)
    at Function.Module._load (node:module:532:12)
    at Module.require (node:module:679:19)
    at require (node:module:810:16)
    at Object.<anonymous> (file:///home/ranadeep/.cache/deno/npm/registry.npmjs.org/@informalsystems/quint/0.22.4/dist/src/cli.js:16:33)

    info: Deno supports CommonJS modules in .cjs files, or when the closest
          package.json has a "type": "commonjs" option.
    hint: Rewrite this module to ESM,
          or change the file extension to .cjs,
          or add package.json next to the file with "type": "commonjs" option,
          or pass --unstable-detect-cjs flag to detect CommonJS when loading.
    docs: https://docs.deno.com/go/commonjs
$ cargo run -p deno -- run -A npm:@informalsystems/quint --version
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.33s
     Running `target/debug/deno run -A 'npm:@informalsystems/quint' --version`
0.22.4

@dsherret dsherret self-requested a review February 1, 2025 00:47
@dsherret
Copy link
Member

dsherret commented Feb 1, 2025

0001-Add-test.patch

@rnbguy thanks! Can you apply this patch?

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

Successfully merging this pull request may close these issues.

require not defined error when cjs module in npm package has no file extension
2 participants