R
Railway14mo ago
Nam

Next.js - "Cannot find module 'x'... " ONLY during build stage

Hi all, I have a Next.js yarn monolith project. I'm trying to deploy on Railway. The error I'm keep getting on Railway: Type error: Cannot find module 'pdf-lib' or its corresponding type declarations. I cannot reproduce this locally when I run yarn install and yarn build. We will appreciate it immensely if you can help us, thanks! More context: We have 2 repos - cronjob and web app, both are Next.js. Recently migrated all of our cronjob code into our web app code for monolith. We have the same app deployed on both Vercel and Railway, and we just wanna use the Railway instance for the purpose of cronjobs. Project id: 00312f09-a0bd-4217-95e0-9f6fbe84ae26
2 Replies
Percy
Percy14mo ago
Project ID: 00312f09-a0bd-4217-95e0-9f6fbe84ae26
Nam
Nam14mo ago
Update on this issue: I've since removed the pdf-lib package and it built with no issue. When I add it back, it ONLY fails to build on railway. I don't know why 😢 Update: switched over to npm and this issue is fixed. This is so weird.