How do you get the current path in Pages?

It looks like __dirname causes a 500 execption. There is no wrangler file for Pages to set the Node JS compatibility to use path.resolve()
8 Replies
Hello, I’m Allie!
Not sure what you mean? Pages doesn't have a filesystem, so it doesn't have a path You can request stuff from the asset server, but you aren't "in" any directories there
cb
cbOP13mo ago
Ah that is what I was trying to do. Load a .json file as a JSON object
Hello, I’m Allie!
Is this in a Function? If so, you can just import the JSON file directly Instead of "reading" it
cb
cbOP13mo ago
No inside of root.tsx for a remix project
Hello, I’m Allie!
Oh, that counts too, since Remix converts its server code to a Function
cb
cbOP13mo ago
How can I just import it directly then?
Hello, I’m Allie!
import someJsonObject from "./data.json";
import someJsonObject from "./data.json";
You might need a type assertion, depending on how Remix handles that
cb
cbOP13mo ago
Perfect thanks
Want results from more Discord servers?
Add your server