Next.js Discord

Discord Forum

Turbopack import JSON from outside project root

Unanswered
Spinge Bib Sqorpnts posted this in #help-forum
Open in Discord
Avatar
Spinge Bib SqorpntsOP
Hello, I am attempting to import a JSON file that resides outside the project folder, and it works perfectly without the --turbo flag.

Snippet:
locale is a state string.
import(`C:/inetpub/wwwroot/Translation/${locale}.json`)
  .then((msgs) => 
  {
    setMessages(msgs.default);
  })
  .catch((e) => console.error('Failed to load messages:', e));

2 Replies

Avatar
Spinge Bib SqorpntsOP
When I run next dev --turbo, it throws a Module not found error
Avatar
joulev
If it works without turbopack and fails with turbopack, that’s turbopack’s bug so (1) please report it as a bug and (2) you can’t do anything other than going back to webpack