technoph1le
FREEOP
9 months ago
Hi, everyone!
I have this following folder structure for my project:
/backend
-> scripts
-> snippetParser.ts
/frontend
/snippetsInside the snippetParser.ts file, there's a following code:
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const snippetPath = join(__dirname, "../../snippets");Basically, when running the code locally, it accesses the snippets perfectly fine, however, after publishing to Railway to run the script on production, it throws an error "No such file or directory".
I'm kinda stuck here. Would love to hear if anyone has a good solution for it.
4 Replies
9 months ago
Hey, how did you deploy your monorepo? By the looks of it, you are deploying a shared monorepo, here is the documentation regarding it: https://docs.railway.com/guides/monorepo#deploying-a-shared-monorepo.
@technoph1le,
import { join } from "path";
import { readdirSync, readFileSync } from "fs";
const snippetPath = join(process.cwd(), "snippets");
console.log("[DEBUG] process.cwd():", process.cwd());
console.log("[DEBUG] snippetPath:", snippetPath);Maybe try this oen