Why does npm run start not work on Vercel?

Information on why commands that start servers may not work with Vercel.
Last updated on March 6, 2024
Runtimes

When deploying your application with Vercel you are prompted for a build command. This command is intended to build your application to generate frontend assets that can be served by the Vercel CDN.

If your build command is npm run startnode app.jsnodemon server.js, or similar, it is likely you are trying to start a server for your application.

The Vercel platform is serverless and designed for static frontends and Serverless FunctionsThere is no running server.

As a result of this, if you are trying to start a server, you are likely to run into difficulties either with your application not starting, or unexpected behavior.

As an alternative to running a server, Vercel allows you to create Serverless Functions, which can be used to execute logic on the server side.

Serverless Functions are stateless and event-driven, which means that they are created to respond to a request and will no longer exist once the response has been sent.

Therefore, it is not possible to store state in-between requests. Any data that needs to be persisted must be stored in a database.

Couldn't find the guide you need?