andykais
andykais3y ago

how to cli run node modules without --compat

So deno run --compat has now been removed in favor of npm: specifiers https://deno.com/blog/v1.26#--compat-mode-removed. I am sure this consolidates a lot of code, but I am unsure how I can gain back certain functionality. For instance, I could run a solidjs template out of the box from deno with compat like so: deno run --compat --unstable --allow-env --allow-read --allow-run --allow-net node_modules/.bin/vite dev Using npm specifiers, I dont seem to have the same capabilities. deno run --compat --unstable --allow-env --allow-read --allow-run npm:vite
error: Uncaught (in promise) Error: Cannot find module 'fs'
Require stack:
- /Users/andrew.kaiser/Library/Caches/deno/npm/registry.npmjs.org/esbuild/0.15.10/lib/main.js
- /Users/andrew.kaiser/Library/Caches/deno/npm/registry.npmjs.org/esbuild/0.15.10/lib/main.js
at Function.Module._resolveFilename (deno:ext/node/02_require.js:609:17)
at Function.Module._load (deno:ext/node/02_require.js:441:29)
at Module.require (deno:ext/node/02_require.js:652:21)
at require (deno:ext/node/02_require.js:777:18)
at Object.<anonymous> (file:///Users/andrew.kaiser/Library/Caches/deno/npm/registry.npmjs.org/esbuild/0.15.10/lib/main.js:1663:10)
at Object.<anonymous> (file:///Users/andrew.kaiser/Library/Caches/deno/npm/registry.npmjs.org/esbuild/0.15.10/lib/main.js:2309:4)
at Module._compile (deno:ext/node/02_require.js:713:36)
at Object.Module._extensions..js (deno:ext/node/02_require.js:740:12)
at Module.load (deno:ext/node/02_require.js:630:34)
at Function.Module._load (deno:ext/node/02_require.js:487:14)
error: Uncaught (in promise) Error: Cannot find module 'fs'
Require stack:
- /Users/andrew.kaiser/Library/Caches/deno/npm/registry.npmjs.org/esbuild/0.15.10/lib/main.js
- /Users/andrew.kaiser/Library/Caches/deno/npm/registry.npmjs.org/esbuild/0.15.10/lib/main.js
at Function.Module._resolveFilename (deno:ext/node/02_require.js:609:17)
at Function.Module._load (deno:ext/node/02_require.js:441:29)
at Module.require (deno:ext/node/02_require.js:652:21)
at require (deno:ext/node/02_require.js:777:18)
at Object.<anonymous> (file:///Users/andrew.kaiser/Library/Caches/deno/npm/registry.npmjs.org/esbuild/0.15.10/lib/main.js:1663:10)
at Object.<anonymous> (file:///Users/andrew.kaiser/Library/Caches/deno/npm/registry.npmjs.org/esbuild/0.15.10/lib/main.js:2309:4)
at Module._compile (deno:ext/node/02_require.js:713:36)
at Object.Module._extensions..js (deno:ext/node/02_require.js:740:12)
at Module.load (deno:ext/node/02_require.js:630:34)
at Function.Module._load (deno:ext/node/02_require.js:487:14)
this most likely has to do with a subprocess with esbuild or something similar, but just in general, it seems like we lost some functionality here
1 Reply
bartlomieju
bartlomieju3y ago
@andykais are you using latest release of Deno? is there a repo I could take a look at? I've been able to successfully run multiple Vite templates (that we added to https://github.com/bluwy/create-vite-extra) so it's not expect that it would fail on missing fs module

Did you find this page helpful?