While uploading Express.js + Admin.js project to Vercel it returns Error [ERR_MODULE_NOT_FOUND]

138 Views Asked by At

I am trying to deploy my express project with adminjs admin panel to vercel, but when I do it, it gives the following error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/back/node_modules/adminjs/lib/locale/de/translation.json' imported from /var/task/back/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) {
  code: 'ERR_MODULE_NOT_FOUND'
}
INIT_REPORT Init Duration: 312.34 ms    Phase: invoke   Status: error   Error Type: Runtime.ExitError
Error: Runtime exited with error: exit status 1
Runtime.ExitError

In my localhost, the whole programs works correct. I do not have any problem with import or require keyword, I have added "type":"module to my package.json file.

My **vercel.json ** file: vercel.json project tree (do not pay attention to node_modules folder, it does not contain an error it is buging

I do not know what is the problem and why I cannot upload my project to vercel, however when I remove admin.js from my project it deploys and works as expected.

Hope you will be able to help me. Thank you in advance!

I have tried to change my vercel.json file, but I did not know what to change so that to fix my problem.

I also tried to write some code so that before building the program vercel would upload all important packages, but it did not help.

I was expecting everything to work without such an error

0

There are 0 best solutions below