acce
acce3mo ago

Importing module is "not found" even though it obviously exists.

I have a new install of deno/fresh. running some deno task build reports an error when attempting to import the fresh.gen.ts file.
error: Uncaught (in promise) TypeError: not found
const manifest = (await import(toFileUrl(join(dir, "fresh.gen.ts")).href))
error: Uncaught (in promise) TypeError: not found
const manifest = (await import(toFileUrl(join(dir, "fresh.gen.ts")).href))
I've tried importing the importing and running the file from a proxy file, and from REPL, all of which say "error: not found". The thing is though, it does exist.
$ ls -la
drwxr-xr-x 10 me me 4096 May 20 11:41 ./
drwxr-xr-x 3 me me 4096 May 20 11:02 ../
-rw-r--r-- 1 me me 179 May 20 11:02 .gitignore
drwxr-xr-x 2 me me 4096 May 20 11:02 .vscode/
-rw-r--r-- 1 me me 363 May 20 11:02 README.md
drwxr-xr-x 2 me me 4096 May 20 11:08 components/
-rw-r--r-- 1 me me 1464 May 20 11:49 deno.jsonc
-rwxrwxrwx 1 me me 233 May 20 11:33 dev.ts*
-rw-r--r-- 1 me me 2880 May 20 11:36 dev_command.ts
-rw-r--r-- 1 me me 160 May 20 11:02 fresh.config.ts
-rwxr--r-- 1 me me 1989 May 20 11:49 fresh.gen.ts*
drwxr-xr-x 2 me me 4096 May 20 11:08 islands/
-rw-r--r-- 1 me me 364 May 20 11:02 main.ts
drwxr-xr-x 4 me me 4096 May 20 11:11 routes/
drwxr-xr-x 4 me me 4096 May 20 11:13 static/
-rw-r--r-- 1 me me 148 May 20 11:02 tailwind.config.ts
$ ls -la
drwxr-xr-x 10 me me 4096 May 20 11:41 ./
drwxr-xr-x 3 me me 4096 May 20 11:02 ../
-rw-r--r-- 1 me me 179 May 20 11:02 .gitignore
drwxr-xr-x 2 me me 4096 May 20 11:02 .vscode/
-rw-r--r-- 1 me me 363 May 20 11:02 README.md
drwxr-xr-x 2 me me 4096 May 20 11:08 components/
-rw-r--r-- 1 me me 1464 May 20 11:49 deno.jsonc
-rwxrwxrwx 1 me me 233 May 20 11:33 dev.ts*
-rw-r--r-- 1 me me 2880 May 20 11:36 dev_command.ts
-rw-r--r-- 1 me me 160 May 20 11:02 fresh.config.ts
-rwxr--r-- 1 me me 1989 May 20 11:49 fresh.gen.ts*
drwxr-xr-x 2 me me 4096 May 20 11:08 islands/
-rw-r--r-- 1 me me 364 May 20 11:02 main.ts
drwxr-xr-x 4 me me 4096 May 20 11:11 routes/
drwxr-xr-x 4 me me 4096 May 20 11:13 static/
-rw-r--r-- 1 me me 148 May 20 11:02 tailwind.config.ts
At this point, I'm a bit out of my depth, and its time to thorw up my hand and ask for help. For ref; * fresh@1.6.8 * deno 1.43.5 (release, x86_64-unknown-linux-gnu) * v8 12.4.254.13 * typescript 5.4.5 * Ubuntu 20.04 - WSL 2 - Windows 10 (inside the ubuntu fs)
5 Replies
acce
acce3mo ago
Just for sanity, I tried running with tsx globally installed in the same Ubuntu env. It found the module fine, but failed on importing stuff that is defined in deno.json -> imports which is exactly what I would expect from a node process. But the goal here was checking file permissions or something like that. But Node/TSX can find it fine. So it 100% exists.
Deno AI Helper
Deno AI Helper3mo ago
I'm sorry to hear you're having trouble with importing the fresh.gen.ts file. I wasn't able to find the answer to your question in the official Deno documentation. From the error message and the code snippet you provided, it seems like the issue might be related to the way the file URL is being constructed or resolved. However, without more context, it's difficult to pinpoint the exact cause of the problem. One thing to check is whether the dir variable in your code snippet contains the correct path to the directory where fresh.gen.ts is located. If dir is not set correctly, the join function might not be creating the correct file path, leading to the "not found" error when trying to import the file. Please note that this advice is not based on the Deno documentation, and I would recommend double-checking the accuracy of the advice given. Make sure that the dir variable is correct and that the path constructed by join(dir, "fresh.gen.ts") is indeed pointing to the existing file. If you continue to experience issues, you might want to reach out to the Deno community or the maintainers of the fresh framework for more specific guidance.
acce
acce3mo ago
That import is coming from the fresh library. importing the file using join is not my code, it comes from deno.land/x/fresh. On top of that, running the file with deno run -A fresh.gen.ts throws the same error. So this is probably a problem with Ubuntu on WSL. Interestingly, I was able to run the code with tsx but got import errors from within the code so it doesn't seem to be a problem with the FS or pathing. Ok, so I've just tried deleting the file and manually creating one with a console log. I can import this perfectly fine, getting the console log as well. As soon as I run deno task start, the newly created file thorws the same errors again. This leads me to thinking there's an error with the fresh library. I just cleared the cache by deleting fresh, esbuild and a few others from /users/me/.cache Rerunning gets the same error after reloading the missing modules.
marvinh.
marvinh.3mo ago
any way we could reproduce the error on our end? Are you on windws?
acce
acce3mo ago
Hey sorry for not updating here. I've actually created an issue for this bug on github. https://github.com/denoland/fresh/issues/2440
GitHub
fresh.gen.ts is not found · Issue #2440 · denoland/fresh
I've been migrating an existing project to WSL Ubuntu installation. First port of call, generating a new fresh project, moving in components/islands/routes/static etc etc. Second port of call, ...