dbushell/sveltekit-adapter-deno

error during build: Error: ENOTEMPTY: directory not empty, rmdir | Windows

Opened this issue · 5 comments

I get an error when building.
When I retry I get the same issue but the build folder is populated with what looks like a good build
Also the path looks weird \\?\C:\...

error during build:
Error: ENOTEMPTY: directory not empty, rmdir '\\?\C:\Users\me\mycodefolder\build\server\chunks'
    at Object.rmdirSync (node:fs:1229:10)
    at _rmdirSync (node:internal/fs/rimraf:260:21)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:250:7)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at Object.rmSync (node:fs:1278:10)
    at Object.rimraf (file:///C:/Users/me/mycodefolder/node_modules/@sveltejs/kit/src/utils/filesystem.js:21:5)
    at adapt (file:///C:/Users/me/mycodefolder/node_modules/sveltekit-adapter-deno/index.js:65:17)
deno 1.39.1 (release, x86_64-pc-windows-msvc)
v8 12.0.267.8
typescript 5.3.3
		"svelte": "^4.2.7",
		"sveltekit-adapter-deno": "^0.12.1",
		"@sveltejs/kit": "^2.0.0",

grafik

Are you providing any config options to the adapter in svelte.config.js?

Are you getting any other error logged before this? If there are earlier errors the build is incomplete.

If not, the build should be OK. The error is the final step to delete the build/server directory (which is temporary).

Try running deno run -A mod.ts inside the build directory and see if it launches.

I don't have a Windows PC to test right now. If you have a mac or Linux machine, or Linux VM/container to try building the same project, that would be very helpful.

no config to the adapter in svelte.config.js

no prior error, the build looks fine, I guess its just a windows path error.
Tested on linux (wsl2) and it works.

when i run deno run -A mod.ts on both systems I get

error: Relative import path "crypto" not prefixed with / or ./ or ../ and not in import map from "file:///home/user/code/myproj/build/server.js"
If you want to use a built-in Node module, add a "node:" prefix (ex. "node:crypto").

But I think this is unrelated and comes from the firebase-admin dependency.
If i remove firebase it works great.

Not sure if sveltekit-adapter-deno can fix the cyrpto import error, could not even get firebase-admin to run on a vanilla deno env

That's good, you can ignore the first error. If the build is OK you can manually delete build/server or just ignore it. Those files get bundled into build/server.js.

The error is coming from https://github.com/dbushell/sveltekit-adapter-deno/blob/main/index.js#L65:

builder.rimraf(`${out}/server`);

where builder is a class provided by SvelteKit. Could be related to sveltejs/kit#10785 — looks similar. I don't think I can do anything to fix it here.

Let's leave this issue open and I'll check back if there's any change on the SvelteKit issue.


The other error would be as you said related to the firebase dependency. You could try adding "crypto":"node:crypto" to the build/import_map.json (see similar issue). Or just "firebase-admin":"npm:firebase-admin" and maybe Deno will automatically resolve the node imports (I have no idea).

There's no easy solution using 3rd modules that are not vanilla JS. They need to run under Node in development and Deno serving the build.

And yeah if firebase-admin doesn't work in vanilla Deno you're out of look.

ah good to know where its coming from.
When I hardcode the path to something windows understands it works, like:

builder.rimraf(`C:\\Users\\myuser\\code\myproj\\build\\/server.js`);

instead of \\?\C:\Users\me\mycodefolder\build\server\ I think windows does not understand this path

Dont know if this is possible or the right place to do it but maybe a windows detection and path translater?


And thx for your help already tried your tips, no luck.
I guess its something google needs to fix, using restApi for now :/

Yes true I should probably be using path that handles the OS/Windows differences. Not sure if that would change anything because all the other paths are working in the build.

No idea where the \\?\ is coming from!

If I have time to set up a Windows VM I'll try and investigate, but I'm very busy right now and Windows is a low priority to be honest!