Repository: deno
Issue: Receiving error when trying to run Sanity based task via npm in node.js interoperability project
Labels: node compat,node resolution

Version: Deno 2.1.6

The script being run from `package.json`
``` json
"typegen": "sanity schema extract --path=src/sanity/extract.json && sanity typegen generate",
```

The output from running the command with `deno task typegen`
```
λ deno task typegen
Task typegen sanity schema extract --path=src/sanity/extract.json && sanity typegen generate
ReferenceError: require is not defined
    at file:///Users/maclong/Developer/quantum/charles-fox-jewellers/node_modules/.deno/yargs@17.7.2/node_modules/yargs/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:///Users/maclong/Developer/quantum/charles-fox-jewellers/node_modules/.deno/sanity@3.70.0/node_modules/sanity/lib/_chunks-cjs/_internal.js:21:383)
Unhandled rejection: ReferenceError: require is not defined
    at file:///Users/maclong/Developer/quantum/charles-fox-jewellers/node_modules/.deno/yargs@17.7.2/node_modules/yargs/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:///Users/maclong/Developer/quantum/charles-fox-jewellers/node_modules/.deno/sanity@3.70.0/node_modules/sanity/lib/_chunks-cjs/_internal.js:21:383)
ReferenceError: require is not defined
    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:///Users/maclong/Developer/quantum/charles-fox-jewellers/node_modules/.deno/sanity@3.70.0/node_modules/sanity/lib/_chunks-cjs/_internal.js:21:383)
    at Object.<anonymous> (file:///Users/maclong/Developer/quantum/charles-fox-jewellers/node_modules/.deno/sanity@3.70.0/node_modules/sanity/lib/_chunks-cjs/_internal.js:3635:4)
Unhandled rejection: ReferenceError: require is not defined
    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:///Users/maclong/Developer/quantum/charles-fox-jewellers/node_modules/.deno/sanity@3.70.0/node_modules/sanity/lib/_chunks-cjs/_internal.js:21:383)
    at Object.<anonymous> (file:///Users/maclong/Developer/quantum/charles-fox-jewellers/node_modules/.deno/sanity@3.70.0/node_modules/sanity/lib/_chunks-cjs/_internal.js:3635:4)
```

> [!NOTE]
> I have utilized `pnpm` to run this script temporarily so it isn't affecting my workflow currently however it would be good to at some point be able to run only Deno and still be able to maintain legacy node projects.