Hello, we are new to vercel and are currently migrating all of our projects to it. We already have a few projects running on it, but there is one which gives us trouble.
It’s a nodejs API and it runs fine on local, but when we deploy it to vercel we get this error: Cannot find module ‘@bull-board/ui/package.json’ Require stack: - /var/task/node_modules/@bull-board/api/dist/src/index.js - /var/task/app.js - /var/task/server.js - /opt/rust/nodejs.js Did you forget to add it to “dependencies” in package.json?
For some reason it doesn’t install this module, I tried to remove the node_modules folder and reinstall and it works locally.
I tested doing vercel build on the repo and in the output I can see that it doesn’t install the dependency, even though it is in the package.json:
Without looking at the whole repository it’s tough to guide what might be going wrong. Although, I do have a suggestion to move away from the legacy APIs (builds and routes) from the Vercel configuration in favor of:
The api start with server.js which then calls the other files, the principal code is in the src folder, Controllers and models contains the functions that will call the db.
The folder and file : helm, cloudbuild.yaml and Dockerfile are useless in this case (they were used when we deployed the project on gcloud)
I’m not sure what information exactly you need, so feel free to ask anything
Hi @empara, thanks for sharing this information. I see that you were previously deploying your application with Docker and gcloud, which is a server environment. Vercel on the other hand is serverless. So, it could be that some parts of the server.js are not exactly in the format that Vercel expects.
If you could share what the project comprises of (frontend, backend, queues etc) that’d be helpful. Also, what does the npm start do, is it just node server.js?
Yes indeed vercel is serverless, but it still worked with other projects that were in a server environment, and they all use express including this one.
The npm start just does “node server.js”
And the code is as follows:
const express = require("express")
const http = require("http")
const app = express()
const server = http.createServer(app)
server.listen(1100, () => console.log(`Listening on port 1100`))
And the project comprises of queues.
I was thinking maybe the problem comes from this part: