Next.js Discord

Discord Forum

dev server freezes after adding localFont

Answered
Argentine hake posted this in #help-forum
Open in Discord
Argentine hakeOP
const pretendard = localFont({
  variable: '--font-pretendard',
  src: '_fonts/PretendardVariable.woff2',
  display: 'swap',
  weight: '45 920',
})

I added this code to layout.tsx and dev server freezes.
Dev server doesn't event print Compiling and it freezes completely.

Next 15.1.5
Answered by Argentine hake
trying upgrading node
View full answer

30 Replies

@Argentine hake js const pretendard = localFont({ variable: '--font-pretendard', src: '_fonts/PretendardVariable.woff2', display: 'swap', weight: '45 920', }) I added this code to layout.tsx and dev server freezes. Dev server doesn't event print Compiling and it freezes completely. **Next** 15.1.5
add a / in front of _fonts. Or if both are in the same folder like this (see attached - my layout consumes), then you can use ./fonts/...
Argentine hakeOP
I tried it but none of them worked (src/fonts src/_fonts ./_fonts ./fonts /fonts /_fonts)
it's the file system path, so it depends on the local project organisation. not everyone has it named fonts
Argentine hakeOP
yes the fonts are located at /src/app/_fonts/PretendardVariable.woff2 and I don't think it is about finding the file
If I give it wrong path, it just complains about the font not existing there
after the dev server freezes, just restarting it does not work, I have to remove .next directory
Argentine hakeOP
yes i literally tried every possible names
Also even if the _ is causing this, freezing is not expected or normal behavior i think
@Argentine hake can you provide a repro of this issue, so we can help you further while you being offline?
Argentine hakeOP
@Argentine hake https://github.com/kappa8719/mail
your project seems to not be executable (see here: https://codesandbox.io/p/github/kappa8719/mail/csb-yzvrs3/draft/eager-clarke?embed=1&file=%2Fpackage.json). Make sure you provide a working code example that clearly shows the error
remove the pretendard localFont declaration and it works fine
@Argentine hake What do you mean by not be executable?
your app isn't executable, even if the localFont is removed. I didn't change any code until now.
Argentine hakeOP
Try using pnpm
npm gives me error too
@B33fb0n3
@Argentine hake Try using pnpm
ah yea, that worked. Also the whole project works fine. Even with the localfont. What steps do I need to do to reproduce the issue?
Argentine hakeOP
how
wait
but how this is possible
Can you try it in local environment? My project doesn't seems to work even after re cloneing the code
@Argentine hake Can you try it in local environment? My project doesn't seems to work even after re cloneing the code
make sure you are using the code from the specific branch and not your main branch 🙂
Argentine hakeOP
I changed font to ttf file and it seems to not crash anymore
though the file type isn't recognized yet
Argentine hakeOP
trying upgrading node
Answer
Argentine hakeOP
it's working, the node package of arch was outdated for 3 weeks