Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run SvelteKit apps using Deno 2 due to handler.js imports #12783

Closed
abdelfattahradwan opened this issue Oct 9, 2024 · 2 comments · Fixed by #12785
Closed

Unable to run SvelteKit apps using Deno 2 due to handler.js imports #12783

abdelfattahradwan opened this issue Oct 9, 2024 · 2 comments · Fixed by #12785
Labels
bug Something isn't working

Comments

@abdelfattahradwan
Copy link

Describe the bug

Attempting to run adapter-node SvelteKit apps using Deno 2 fails due to inconsistent imports in the generated handler.js file.

Reproduction

Given any new or preexisting SvelteKit app using adapter-node:

  • Run the build task.
  • Navigate to the build (or whatever your output directory is called).
  • Run deno run ./index.js (Make sure you have Deno installed).
  • The command errors out, and the app doesn't run.

Logs

error: Relative import path "path" not prefixed with / or ./ or ../
  hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:path").
    at file:///[REDACTED]/build/handler.js:7:42

System Info

System:
	OS: Windows 11 10.0.22631
	CPU: (28) x64 Intel(R) Core(TM) i7-14700K
	Memory: 40.44 GB / 63.77 GB
Binaries:
	Node: 20.18.0 - C:\Program Files\nodejs\node.EXE
	npm: 10.9.0 - ~\AppData\Roaming\npm\npm.CMD
	pnpm: 9.0.6 - ~\AppData\Local\pnpm\pnpm.CMD
	bun: 1.1.30 - ~\.bun\bin\bun.EXE
Browsers:
	Edge: Chromium (127.0.2651.74)
	Internet Explorer: 11.0.22621.3527
npmPackages:
	@sveltejs/adapter-node: ^5.2.5 => 5.2.5
	@sveltejs/kit: ^2.6.4 => 2.6.4
	@sveltejs/vite-plugin-svelte: ^3.1.2 => 3.1.2
	svelte: ^4.2.19 => 4.2.19
	vite: ^5.4.8 => 5.4.8

Severity

serious, but I can work around it

Additional Information

I am testing running my SvelteKit apps with the just-released Deno 2 runtime. Sadly, I cannot easily do that due to the inconsistent imports in handler.js. Some are prefixed with node: and some aren't, which causes Deno to log the following message and fail:

error: Relative import path "path" not prefixed with / or ./ or ../
  hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:path").
    at file:///[REDACTED]/build/handler.js:7:42

The line in question is:

// handler.js
import { resolve, join, normalize } from 'path'; // Line 7

And above it are two other lines that cause the same issue:

// handler.js
import * as fs from 'fs'; // Line 5
import { readdirSync, statSync } from 'fs'; // Line 6

Surprisingly, all other imports are prefixed with node: or are relative, so they don't cause any issues. Indeed, manually modifying the handler.js file after each build fixes the problems and makes the SvelteKit app run flawlessly. But that becomes tedious too quickly.

@benmccann
Copy link
Member

See denoland/deno#17248 (comment)

@Conduitry
Copy link
Member

I'm removing the 'blocked by upstream' label. It looks like this is pretty easy to take care of in our own build process for the runtime parts of the adapter - #12785.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants