Error When Deploy

The app works fine locally using vercel dev, but when deploying to Vercel, the logs show:

Cannot find module 'express'
Require stack:
- /var/task/app.js
Did you forget to add it to "dependencies" in `package.json`?
Node.js process exited with exit status: 1.

Expected Behavior

The app should deploy successfully on Vercel without missing module errors.

Current Behavior

Fails to deploy due to missing express module, even though it’s listed in package.json dependencies.

package.json

{
  "name": "seed-tracker",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "cookie-parser": "~1.4.4",
    "debug": "~2.6.9",
    "http-errors": "~1.6.3",
    "jade": "~1.11.0",
    "morgan": "~1.9.1",
    "axios": "^1.8.3",
    "cors": "^2.8.5",
    "express": "^4.21.2"
  }
}

vercel.json

{
    "version": 2,
    "builds": [
        {
            "src": "app.js",
            "use": "@vercel/node"
        },
        {
            "src": "public/**",
            "use": "@vercel/static"
        }
    ],
    "routes": [
        {
            "src": "/public/(.*)",
            "dest": "/public/$1"
        },
        {
            "src": "/(.*)",
            "dest": "app.js"
        }
    ]
}

If you’re having trouble deploying an Express app, this guide can help.

You can also ask v0 for suggestions tailored to your own project setup.

Hi, @yuusukealmal! Welcome to the Vercel Community :waving_hand:

Could you go through this post? Might be helpful!

2 Likes