svelte-adapter-deno icon indicating copy to clipboard operation
svelte-adapter-deno copied to clipboard

Getting an error with `deno run --allow-env --allow-read --allow-net path/to/build/index.js`

Open xanderjakeq opened this issue 2 years ago • 8 comments

If you want to use a built-in Node module, add a "node:" prefix (ex. "node:assert").
    at file:////sveltekit/server/chunks/firebaseAdmin-918fac7a.js:20:26
      const module = await import('./hooks.server-8f6f964b.js');

I get this error after building with svelte-adapter-deno. Not sure what I did wrong.

xanderjakeq avatar Feb 01 '23 02:02 xanderjakeq

Hey @xanderjakeq are you trying to import a node module, or is it one of your package dependencies that is importing a node-specific dependency? If so, you may need to patch it to import using the node: specifier for Deno compatibility.

jpaquim avatar Feb 01 '23 10:02 jpaquim

I don't know.. i think it's my dependencies. This is happening in the build files, so am I editing them directly?

xanderjakeq avatar Feb 01 '23 16:02 xanderjakeq

I've got a bunch of these on a project I'm trying this out with as well. For assert, fs, buffer etc.
I suppose this adapter only checks the direct dependencies, and not deps of deps?

oskarhane avatar Feb 02 '23 13:02 oskarhane

This is pretty much where we are at in #38

drewbitt avatar Feb 02 '23 22:02 drewbitt

It does seem to be related, and maybe related to some difference in bundling the built-in node: modules between rollup and esbuild. @drewbitt, @oskarhane, @xanderjakeq could you maybe provide a minimal reproduction just to help with the debugging and to understand if the root cause is the same for your issues?

jpaquim avatar Feb 06 '23 10:02 jpaquim

have a simmilar issue

TypeError: Relative import path "dns" not prefixed with / or ./ or ../
If you want to use a built-in Node module, add a "node:" prefix (ex. "node:dns").

code is pretty simple just a +server.ts with

export async function GET(request: RequestEvent) {
	const nameParam = request.url.searchParams.get('name');

	if (!nameParam || nameParam === '_') {
		return defaultResponse();
	}
	// do stuff and send response
	...
}
deno 1.39.1 (release, x86_64-pc-windows-msvc)
v8 12.0.267.8
typescript 5.3.3
		"svelte": "^4.2.7",
		"svelte-adapter-deno": "^0.9.0",
		"@sveltejs/kit": "^2.0.0",

I tried adding node:dns but same issue

1-leo avatar Jan 03 '24 11:01 1-leo

@leo-lox according to https://github.com/dbushell/sveltekit-adapter-deno/issues/5#issuecomment-1785922436, this project will likely not receive any updates any time soon and the other adapter is a bit more up to date with fixes.

drewbitt avatar Jan 03 '24 15:01 drewbitt

thx, I did not see that

1-leo avatar Jan 03 '24 16:01 1-leo