Font module not found
Unanswered
Dwarf Crocodile posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
Folder structure is:
-public - "font1.ttf"
-src - app - ui - font.ts
font.ts code is:
I am geeting this error:
-public - "font1.ttf"
-src - app - ui - font.ts
font.ts code is:
import { Rajdhani } from "next/font/google";
import localFont from "next/font/local";
export const rajdhani = Rajdhani({
weight: ["700"],
subsets: ["latin"],
});
export const font1 = localFont({
src: "./font1.ttf",
});
I am geeting this error:
src\app\ui\fonts.ts
Module not found: Can't resolve './font1.ttf'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./src/app/ui/fonts.ts
./src/app/page.tsx
29 Replies
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/aff4eeb34922ca980b0d5fbb5bc60c21.webp?size=256)
risky
can you maybe try ../ ntill you get the font (i think its relative to file and not public like images)
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
getting this :
src\app\ui\fonts.ts
Module not found: Can't resolve '../font1.ttf'
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/aff4eeb34922ca980b0d5fbb5bc60c21.webp?size=256)
risky
maybe more ../ as you are in ui folder which is a few folders down from where public is
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
but public folder contents can be imported using "./filename"
?
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/aff4eeb34922ca980b0d5fbb5bc60c21.webp?size=256)
risky
yeah but this is next/font and that isn't the same as importing static files link image would be
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
nothing working:
and
src\app\ui\fonts.ts
Module not found: Can't resolve '../../../../public/font1.ttf'
and
src\app\ui\fonts.ts
Module not found: Can't resolve '../../../../font1.ttf'
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/aff4eeb34922ca980b0d5fbb5bc60c21.webp?size=256)
risky
wait can you actually use ttf with next/font (i have only tried it with woff) - id hope you can
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
![Image](https://cdn.discordapp.com/attachments/1210938598921216070/1210940460772884530/image.png?ex=65ec6330&is=65d9ee30&hm=810fd472de1b1eb33c0520b74e8346b47e65cc5dc92c4b83ef73398655e3bd35&)
idk about that 😦
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/aff4eeb34922ca980b0d5fbb5bc60c21.webp?size=256)
risky
like i know i had to ../ into publicj from app dir to get my public font
![Image](https://cdn.discordapp.com/attachments/1210938598921216070/1210940685130145833/image.png?ex=65ec6365&is=65d9ee65&hm=66246bda50d99ea89d8b43d8ddc548bf7dda156118620b7c289904d371fc12f3&)
and they use ttf as an example 👀
![Image](https://cdn.discordapp.com/attachments/1210938598921216070/1210940910624440411/image.png?ex=65ec639b&is=65d9ee9b&hm=fc64303b817296524a1bc1134ce13033e1667d9986ce5d865c61c404118d6336&)
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
src\app\ui\fonts.ts
Module not found: Can't resolve '../../../../font2.otf'
Module not found: Can't resolve '../../../../font2.otf'
not working with otf too
tried :
all the combinations
all the combinations
wait..let me keep all the font files in 'ui' folder
now,
font.ts
and font1.ttf
are in same folder ui
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/aff4eeb34922ca980b0d5fbb5bc60c21.webp?size=256)
risky
wait did you ever ../../public
![Image](https://cdn.discordapp.com/attachments/1210938598921216070/1210941601665388544/image.png?ex=65ec6440&is=65d9ef40&hm=0914b0ebc2cf1c15cc00d00bce78283b0c1aeb7842be4f4195efa8d226987f0f&)
as you are going down folders but i see not going into the public
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
did that...not working
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/aff4eeb34922ca980b0d5fbb5bc60c21.webp?size=256)
risky
oh 😦
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
did this
still not workin
src: "./font2.otf",
still not workin
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/aff4eeb34922ca980b0d5fbb5bc60c21.webp?size=256)
risky
and you reset .next folder and all ðŸ˜
yeah i have no idea what next/font's issue is
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
wait...it worked
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/aff4eeb34922ca980b0d5fbb5bc60c21.webp?size=256)
risky
👀
what did you do to fix it 🎉
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Dwarf CrocodileOP
this 🙂
and "./font1.tff"