Font module not found
Unanswered
Dwarf Crocodile posted this in #help-forum
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
can you maybe try ../ ntill you get the font (i think its relative to file and not public like images)
Dwarf CrocodileOP
getting this :
src\app\ui\fonts.ts
Module not found: Can't resolve '../font1.ttf'
maybe more ../ as you are in ui folder which is a few folders down from where public is
Dwarf CrocodileOP
but public folder contents can be imported using "./filename"
?
yeah but this is next/font and that isn't the same as importing static files link image would be
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'
wait can you actually use ttf with next/font (i have only tried it with woff) - id hope you can
Dwarf CrocodileOP
@risky wait can you actually use ttf with next/font (i have only tried it with woff) - id hope you can
Dwarf CrocodileOP
idk about that 😦
and they use ttf as an example 👀
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
as you are going down folders but i see not going into the public
Dwarf CrocodileOP
did that...not working
oh 😦
@Dwarf Crocodile now, `font.ts` and `font1.ttf` are in same folder `ui`
Dwarf CrocodileOP
did this
still not workin
src: "./font2.otf",
still not workin
and you reset .next folder and all ðŸ˜
yeah i have no idea what next/font's issue is
Dwarf CrocodileOP
wait...it worked
👀
@Dwarf Crocodile wait...it worked
what did you do to fix it 🎉
@Dwarf Crocodile now, `font.ts` and `font1.ttf` are in same folder `ui`
Dwarf CrocodileOP
this 🙂
and "./font1.tff"