Repository: deno
Issue: require not defined error when cjs module in npm package has no file extension
Labels: bug

Version: Deno 2.1.0

Last working version `2.0.6`.
```console
$ docker run --rm -it denoland/deno:alpine-2.0.6 run -A npm:@informalsystems/quint@0.22.4 --version
Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed:
┠─ npm:protobufjs@7.4.0
┃
┠─ This may cause the packages to not work correctly.
┠─ Lifecycle scripts are only supported when using a `node_modules` directory.
┠─ Enable it in your deno config file:
┖─ "nodeModulesDir": "auto
0.22.4
```

But for `>=2.1.0`, I am getting error for commonjs.
```console
$ docker run --rm -it denoland/deno:alpine-2.1.0 run -A npm:@informalsystems/quint@0.22.4 --version
Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed:
┠─ npm:protobufjs@7.4.0
┃
┠─ This may cause the packages to not work correctly.
┠─ Lifecycle scripts are only supported when using a `node_modules` directory.
┠─ Enable it in your deno config file:
┖─ "nodeModulesDir": "auto"
error: Uncaught (in promise) ReferenceError: require is not defined
    at file:///deno-dir/npm/registry.npmjs.org/yargs/17.7.2/yargs:3:69
    at loadESMFromCJS (node:module:761:21)
    at Module._compile (node:module:722:12)
    at Object.Module._extensions..js.Module._extensions..ts.Module._extensions..jsx.Module._extensions..tsx (node:module:754:10)
    at Module.load (node:module:662:32)
    at Function.Module._load (node:module:534:12)
    at Module.require (node:module:681:19)
    at require (node:module:797:16)
    at Object.<anonymous> (file:///deno-dir/npm/registry.npmjs.org/@informalsystems/quint/0.22.4/dist/src/cli.js:16:33)
    at Object.<anonymous> (file:///deno-dir/npm/registry.npmjs.org/@informalsystems/quint/0.22.4/dist/src/cli.js:356:4)

    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.
    docs: https://docs.deno.com/go/commonjs

$ docker run --rm -it denoland/deno:alpine-2.1.1 run -A npm:@informalsystems/quint@0.22.4 --version
< same error as before >
```

In `2.1.2`, I do get a suggestion for `--unstable-detect-cjs`.
```console
$ docker run --rm -it denoland/deno:alpine-2.1.2 run -A npm:@informalsystems/quint@0.22.4 --version
Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed:
┠─ npm:protobufjs@7.4.0
┃
┠─ This may cause the packages to not work correctly.
┠─ Lifecycle scripts are only supported when using a `node_modules` directory.
┠─ Enable it in your deno config file:
┖─ "nodeModulesDir": "auto"
error: Uncaught (in promise) ReferenceError: require is not defined
    at file:///deno-dir/npm/registry.npmjs.org/yargs/17.7.2/yargs:3:69
    at loadESMFromCJS (node:module:777:21)
    at Module._compile (node:module:722:12)
    at loadMaybeCjs (node:module:770:10)
    at Object.Module._extensions..js (node:module:761:12)
    at Module.load (node:module:662:32)
    at Function.Module._load (node:module:534:12)
    at Module.require (node:module:681:19)
    at require (node:module:812:16)
    at Object.<anonymous> (file:///deno-dir/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
 ```
 
 But it still doesn't work with `--unstable-detect-cjs` flag.
 
 ```console
$ docker run --rm -it denoland/deno:alpine-2.1.2 run --unstable-detect-cjs -A npm:@informalsystems/quint@0.22.4 --version
...
< still same error >
```