Deployment not working with Strapi

Current behavior:

Expected Behavior:

repo-root/
. . front-end/ → Deploys to vercel-project-arbitrary-name-1
. . . . package.json → See package.json#2
. . back-end/ → Deploys to vercel-project-arbitrary-name-2
. . . . package.json → See package.json#3
package.json → See package.json#1

package.json#1

{
    "name": "<ROOT_NAME>",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "dev": "concurrently \"yarn workspace frontend dev\" \"yarn workspace backend develop\"",
        "build": "yarn workspace frontend build && yarn workspace backend build",
        "start": "concurrently \"yarn workspace frontend start\" \"yarn workspace backend start\""
    },
    "keywords": [],
    "author": "",
    "license": "ISC"
}

package.json#2

{
    "name": "frontend",
    "version": "0.1.0",
    "private": true,
    "scripts": {
        "dev": "next dev --turbopack",
        "build": "next build",
        "start": "next start",
        "lint": "next lint"
    },
    "dependencies": {
        "@clerk/nextjs": "^6.5.2",
        "@heroicons/react": "^2.2.0",
        "@radix-ui/react-collapsible": "^1.1.1",
        "@radix-ui/react-dialog": "^1.1.2",
        "@radix-ui/react-label": "^2.1.0",
        "@radix-ui/react-separator": "^1.1.0",
        "@radix-ui/react-slot": "^1.1.0",
        "@radix-ui/react-tooltip": "^1.1.4",
        "@shadcn/ui": "^0.0.4",
        "class-variance-authority": "^0.7.1",
        "clsx": "^2.1.1",
        "lucide-react": "^0.462.0",
        "next": "15.0.3",
        "react": "19.0.0-rc-66855b96-20241106",
        "react-dom": "19.0.0-rc-66855b96-20241106",
        "tailwind-merge": "^2.5.5",
        "tailwindcss-animate": "^1.0.7",
        "vercel": "^39.1.2"
    },
    "devDependencies": {
        "@types/node": "^20",
        "@types/react": "^18",
        "@types/react-dom": "^18",
        "eslint": "^8",
        "eslint-config-next": "15.0.3",
        "postcss": "^8",
        "tailwindcss": "^3.4.1",
        "typescript": "^5"
    }
}

package.json#3

{
  "name": "backend",
  "version": "0.1.0",
  "private": true,
  "description": "A Strapi application",
  "scripts": {
    "build": "strapi build",
    "deploy": "strapi deploy",
    "develop": "strapi develop",
    "start": "strapi start",
    "strapi": "strapi"
  },
  "dependencies": {
    "@strapi/plugin-cloud": "5.4.2",
    "@strapi/plugin-users-permissions": "5.4.2",
    "@strapi/strapi": "5.4.2",
    "better-sqlite3": "11.3.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-router-dom": "^6.0.0",
    "styled-components": "^6.0.0"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "typescript": "^5"
  },
  "engines": {
    "node": ">=18.0.0 <=22.x.x",
    "npm": ">=6.0.0"
  },
  "strapi": {
    "uuid": "<REDACTED>"
  }
}

Current build behavior works for frontend which looks like:

Current build behavior does not work for backend which looks like:

Back-end: Strapi v5

Hi @lcpichette, thanks for posting this question on the community.

The context you provided will come very handy. Did you already check the build and deployment logs for these projects? Could you share the error messages from the logs (if they don’t include sensitive information)?

No project logs (Pressed refresh query as well)

Here are the build logs (Anything wrapped in < > is redacted but correct):

[23:52:00.173] Running build in Washington, D.C., USA (East) – iad1
[23:52:00.793] Cloning github.com/<GITHUB_USER>/<MONOREPO_NAME> (Branch: main, Commit: <COMMIT_HASH>)
[23:52:01.481] Previous build cache not available
[23:52:02.046] Cloning completed: 1.253s
[23:52:02.471] Running "vercel build"
[23:52:02.883] Vercel CLI 39.1.1
[23:52:03.610] Detected `pnpm-lock.yaml` version 9 generated by pnpm@9.x
[23:52:03.610] Running "install" command: `pnpm install`...
[23:52:04.389] Lockfile is up to date, resolution step is skipped
[23:52:04.489] Progress: resolved 1, reused 0, downloaded 0, added 0
[23:52:04.729] Packages: +1297
[23:52:04.729] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[23:52:05.490] Progress: resolved 1297, reused 0, downloaded 58, added 48
[23:52:06.499] Progress: resolved 1297, reused 0, downloaded 164, added 153
[23:52:07.499] Progress: resolved 1297, reused 0, downloaded 253, added 237
[23:52:08.499] Progress: resolved 1297, reused 0, downloaded 393, added 381
[23:52:09.499] Progress: resolved 1297, reused 0, downloaded 498, added 486
[23:52:10.500] Progress: resolved 1297, reused 0, downloaded 593, added 582
[23:52:11.501] Progress: resolved 1297, reused 0, downloaded 719, added 712
[23:52:12.502] Progress: resolved 1297, reused 0, downloaded 949, added 948
[23:52:13.505] Progress: resolved 1297, reused 0, downloaded 1063, added 1066
[23:52:14.503] Progress: resolved 1297, reused 0, downloaded 1290, added 1296
[23:52:15.050] Progress: resolved 1297, reused 0, downloaded 1291, added 1297, done
[23:52:15.477] .../node_modules/core-js-pure postinstall$ node -e "try{require('./postinstall')}catch(e){}"
[23:52:15.478] .../node_modules/@swc/core postinstall$ node postinstall.js
[23:52:15.520] .../node_modules/better-sqlite3 install$ prebuild-install || node-gyp rebuild --release
[23:52:15.521] .../node_modules/msw postinstall$ node -e "try{require('./config/scripts/postinstall')}catch(e){}"
[23:52:15.522] .../esbuild@0.21.3/node_modules/esbuild postinstall$ node install.js
[23:52:15.553] .../node_modules/core-js-pure postinstall: Done
[23:52:15.607] .../node_modules/@swc/core postinstall: Done
[23:52:15.621] .../esbuild@0.20.2/node_modules/esbuild postinstall$ node install.js
[23:52:15.640] .../node_modules/msw postinstall: Done
[23:52:15.683] .../sharp@0.32.6/node_modules/sharp install$ (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
[23:52:15.683] .../esbuild@0.21.3/node_modules/esbuild postinstall: Done
[23:52:15.758] .../esbuild@0.20.2/node_modules/esbuild postinstall: Done
[23:52:15.794] .../esbuild@0.16.17/node_modules/esbuild postinstall$ node install.js
[23:52:15.926] .../esbuild@0.16.17/node_modules/esbuild postinstall: Done
[23:52:15.972] .../sharp@0.32.6/node_modules/sharp install: sharp: Using cached /vercel/.npm/_libvips/libvips-8.14.5-linux-x64.tar.br
[23:52:16.173] .../node_modules/better-sqlite3 install: Done
[23:52:16.418] .../sharp@0.32.6/node_modules/sharp install: sharp: Integrity check passed for linux-x64
[23:52:16.607] .../sharp@0.32.6/node_modules/sharp install: Done
[23:52:16.846] 
[23:52:16.846] dependencies:
[23:52:16.846] + @strapi/plugin-cloud 5.4.2
[23:52:16.847] + @strapi/plugin-users-permissions 5.4.2
[23:52:16.847] + @strapi/strapi 5.4.2
[23:52:16.847] + better-sqlite3 11.3.0
[23:52:16.847] + react 18.3.1
[23:52:16.847] + react-dom 18.3.1
[23:52:16.847] + react-router-dom 6.28.0
[23:52:16.847] + styled-components 6.1.13
[23:52:16.847] 
[23:52:16.847] devDependencies:
[23:52:16.847] + @types/node 20.17.9
[23:52:16.847] + @types/react 18.3.12
[23:52:16.847] + @types/react-dom 18.3.1
[23:52:16.847] + typescript 5.7.2
[23:52:16.847] 
[23:52:16.862] Done in 13.1s
[23:52:17.587] 
[23:52:17.588] > backend@0.1.0 build /vercel/path0/backend
[23:52:17.588] > strapi build
[23:52:17.588] 
[23:52:19.807] - Compiling TS
[23:52:21.888] ✔ Compiling TS (2082ms)
[23:52:21.889] - Building build context
[23:52:21.889] 
[23:52:21.999] /bin/sh: line 1: hostname: command not found
[23:52:22.001] [INFO] Including the following ENV variables as part of the JS bundle:
[23:52:22.001]     - ADMIN_PATH
[23:52:22.001]     - STRAPI_ADMIN_BACKEND_URL
[23:52:22.001]     - STRAPI_TELEMETRY_DISABLED
[23:52:22.146] ✔ Building build context (253ms)
[23:52:22.146] - Building admin panel
[23:52:22.147] 
[23:52:45.231] ✔ Building admin panel (23090ms)
[23:52:45.442] Build Completed in /vercel/output [42s]
[23:52:45.525] Deploying outputs...
[23:52:47.881] 
[23:52:48.149] Deployment completed
[23:53:15.805] Uploading build cache [95.05 MB]...
[23:53:16.875] Build cache uploaded: 1.069s

Hi @lcpichette, thanks for the reply.

The build logs look fine.

By default, the logs are set for Past 30 minutes (see left pane). So, if you make new requests and then check the logs, we might find error logs to debug.Could you try visiting the page again and then check the logs?

Also, check the logs for both the frontend and backend project.

Video shown and then removed (Video shows no logs upon refresh of deployed site, deployed site which shows the same error referenced in this post’s description).

Hey, I saw the video. Thanks for sharing it. You can edit the comment to remove the link now.

Let me dig a bit more to see how we can debug it.

1 Like

Hi @lcpichette, from the build logs I see that the output of the build seems to be /build folder. Can you update the project settings to use the /build folder as the Output Directory?

I’d also recommend comparing your project configurations with the nextjs-corporate-starter/backend/README.md at main · strapi/nextjs-corporate-starter · GitHub example we have.

1 Like

Changing the output directory to build and /build then redeploying from main did not fix the issue sadly : (

Where do you see the output of the build being the /build folder?

Below is a screenshot showing the build step, and the only output path I see referenced is /vercel/output.

I tried setting the output directory as /vercel/output and vercel/output and neither worked as well.

I noticed that there’s a vercel-deploy plugin but it’s only compatible with strapi v4. Vercel Deploy | Strapi Market I wonder if it’s just not possible to deploy Strapi v4.9+ projects to Vercel without custom extensions for it? The link you sent me is for strapi 4.2. I’m running a Strapi v5 project.

Hi @lcpichette, thanks for sharing the outcome. My guess was that some frameworks output the build to /build instead of /dist. You can see that for your project in the Deployment section, see this image:

The /vercel/output is an internal space for the Vercel platform and shouldn’t be used or referred to elsewhere.

Let me try and recreate this issue with you.

I appreciate the info and you trying to reproduce the issue! Just let me know if there’s any other info you need.

Hi @lcpichette, I did some digging around and found out that the output for the Strapi CMS itself is supposed to be hosted on a server instance (EC2 or similar) instead of a serverless platform like Vercel.

You can read more about Strapi CMS deployment on their documentation.

However, you can deploy the frontend application on Vercel. I tried running their latest LaunchPad project and it uses Next.js for the frontend website, so you can definitely follow this repository to deploy the frontend. But, the /strapi part of this also builds into a server application because of all the system requirements such as a database and OS utilities.

I hope this was helpful.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.