404: NOT_FOUND Code: NOT_FOUND

I deployed my Node.js express application, status of deployment = Ready, unfortunately it returned:
404: NOT_FOUND Code: NOT_FOUND ID: gru1:gru1::zph5r-1730229227559-5f387b64f0d3

My project: GitHub - Matt-Gary/Project-Believe: Creating a website for the Believe calisthenics group

I already tried steps in Debugging 404 Errors

Didn’t work.

Deployment URL or Custom Domain: https://project-believe.vercel.app/
Project Framework: Express
Node/Runtime Version: v20.15.0

{ "version": 2, 
"rewrites": [{"source": "/(.*)", "dest":"/"}] }

Thanks for sharing the repo! It looks like the “check the deployment output” section of the 404 debugging post has the answer. :smile:

If the project uses a traditionally server-side framework, such as Express , you should make sure to put the index.js file in a /api directory so it will be deployed as a serverless function. In that case the path to the first page of your site would look like my-website.com/api which can be altered to use the root path / using rewrites .

You can find more info and a complete example project in this guide

I did everything, but still not working. I changed the folder structure of my project but no result :frowning:

added also

{
  "version": 2,
  "builds": [
    {
      "src": "api/index.js",
      "use": "@vercel/node"
    }
  ],
  "routes": [
    {
      "src": "/(.*)",
      "dest": "api/index.js"
    }
  ]
}

I don’t know what I’m doing wrong

Something like this would probably work better for your project given the structure it had when I looked earlier. But with { "rewrites": [{ "source": "/(.*)", "destination": "/api" }] } as the vercel.json instead of the builds configuration used in the article.

It worked! Now I have another problem. Trying to connect database created in Neon.Tech
I created a new variable in vercel ALSO I integrated NEON with Vercel.
DATABASE_URL: postgresql://believe_project_owner:7bsei2mwEcqk@ep-crimson-firefly-a57056qt.us-east-2.aws.neon.tech/believe_project?sslmode=require

Configurate database within my project. But it returned error:

Error: Please install pg package manually
    at ConnectionManager._loadDialectModule (/var/task/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:55:15)
    at new ConnectionManager (/var/task/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:15:24)
    at new PostgresDialect (/var/task/node_modules/sequelize/lib/dialects/postgres/index.js:13:30)
    at new Sequelize (/var/task/node_modules/sequelize/lib/sequelize.js:194:20)
    at Object.<anonymous> (/var/task/models/index.js:16:15)
    at Module.<anonymous> (/opt/rust/bytecode.js:1:1435)
    at l._compile (/opt/rust/bytecode.js:1:3140)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.

Also updated my package.json

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server",
    "dev": "nodemon",
    "vercel-build": "npx sequelize-cli db:migrate",
    "seed": "npx sequelize-cli db:seed:all"
  },

Please help, when I’m testing database on my local machine it is working.

The error suggests that the pg package is needed but not included in the project. Is the package missing from package.json?

I found this Stack Overflow post with more details about the error and suggested solutions: node.js - “Error: Please install pg package manually” when trying to run “npm run serve:dev”? - Stack Overflow

The thing is that locally everything’s working. I connected my project with Neon database and it works correctly, create tables, also CRUD operations are working. Only when I deploy my website in Vercel, it returns this error. Like I said I even integrate Vercel with Neon but still returning this error.

It looks like on the Vercel level there is some issue.
Do you have any idea what it can be?

Dependencies in package.json

"pg": "^8.12.0",

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