@bull-board/api not working on Vercel

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:


image

I tried to force the installation with a postinstall in the scripts in the package.json file, but it didn’t work either.
image

This is my vercel.json file:

Does someone know how to fix this ?

Hi @empara, welcome to the Vercel Community!

Sorry to see you are facing this issue.

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:

{
  "rewrites": [{ "source": "/(.*)", "destination": "/server" }]
}

Can you help me with some more information:

  • What is the folder structure for your project?
  • How do you run the project locally?
1 Like

Hello @anshumanb, thank you for your reply :slight_smile:

To start the api locally, I just do npm i (if needed) and npm start

The architecture looks like this:

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

1 Like

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.

I’d recommend giving Using Express.js with Vercel a read.

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?

1 Like

Hello,

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:

const { ExpressAdapter } = require("@bull-board/express")
const { createBullBoard } = require("@bull-board/api")
const { BullAdapter } = require("@bull-board/api/bullAdapter")
const serverAdapter = new ExpressAdapter()

serverAdapter.setBasePath("/admin/queues")
const { addQueue, removeQueue, setQueues, replaceQueues } = createBullBoard({
	queues: [new BullAdapter(stripeQueue)],
	serverAdapter: serverAdapter,
})

But I don’t see why this would block the dependency @bull-board/ui to be installed

Hi @empara, thanks for the information. I think I found the culprit.

There’s an open issue on the bull-board repository but one of the comment got it working on Vercel. So can you try this solution:

I hope this helps. Please do share the outcome here.

1 Like