svelte-adapter-deno
svelte-adapter-deno copied to clipboard
Use 'fs': Dynamic require of "fs" is not supported
After building, running my Sveltekit project with deno run --allow-env --allow-read --allow-net build/index.js fails with
error: Uncaught Error: Dynamic require of "fs" is not supported
throw new Error('Dynamic require of "' + x2 + '" is not supported');
I use a single readdir command in my Sveltekit backend
import { readdir } from 'fs/promises';
...
const files = await readdir(...);
To my deps.ts file I have added
export { readdir } from "https://deno.land/[email protected]/node/fs/promises.ts";
// export { fs } from "node:fs";
// export { readdir } from "node:fs/promises";
export { exists } from 'https://deno.land/[email protected]/fs/mod.ts';
export { dirname, extname, fromFileUrl, join } from "https://deno.land/[email protected]/path/mod.ts";
export { Application } from 'https://deno.land/x/[email protected]/mod.ts';
The readdir import does not remove the error and the built-in fs imports do not work
X [ERROR] Could not resolve "node:fs"
.svelte-kit/deno/deps.ts:3:19:
3 │ export { fs } from "node:fs";
╵ ~~~~~~~~~
The package "node:fs" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
Are 'fs' and other built-in node modules expected to work?