Error when deploying NestJS (with AdminJS) app to Vercel

118 views Asked by At

I'm trying to deploy a NestJS project that additionally uses AdminJS to Vercel, but I'm getting this error:

[31m[Nest] 8  - [39m01/17/2024, 10:32:50 AM [31m  ERROR[39m 
[38;5;3m[ExceptionHandler] [39m[31mCannot find module 
'/var/task/node_modules/adminjs/lib/locale/de/translation.json' imported from 
/var/task/node_modules/adminjs/lib/locale/index.js[39m
Error: Cannot find module 
'/var/task/node_modules/adminjs/lib/locale/de/translation.json' imported from 
/var/task/node_modules/adminjs/lib/locale/index.js
at new NodeError (node:internal/errors:405:5)
at finalizeResolution (node:internal/modules/esm/resolve:332:11)
at moduleResolve (node:internal/modules/esm/resolve:995:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:939:12)
at defaultResolve (node:internal/modules/esm/resolve:1181:79)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36)
INIT_REPORT Init Duration: 1759.70 ms   Phase: init Status: error   Error Type: 
Runtime.ExitError

I found questions about this issue, but no solutions. I'm curious if anyone else encountered this and maybe solved it.

EDIT: I didn't specify the versions:

  • NestJS: 10.0.0
  • AdminJS: 7.5.2
  • Node.js 18.x

EDIT: It seems that when the app is deployed to Vercel, the .json files used by the AdminJS dependency are missing in the build

Comparison of node_modules locally and on vercel build

0

There are 0 answers