Reputation: 568
I have the following scripts in my package.json
"scripts": {
"dev": "nodemon --exec babel-node src/index.js",
"build": "NODE_ENV=PRODUCTION babel src -d dist --copy-files",
"serve": "NODE_ENV=production node dist/index.js"
},
My application builds, but only the dist/index.js
is just served up as a file rather than being run.
I have tried to change serve
to start
but no luck.
Have also tried to run the serve
script as part of the build
with &&
- this yielded a build process that just runs.
I feel like the solution is trivial, and I am just making mistake with my scripts.
Any ideas?
Upvotes: 2
Views: 2008
Reputation: 2105
I would suggest you either you leverage the vercel serverless functions
config, or you set it up the old way, using a vercel.json
file that contains:
once you deploy your code to vercel, you need to :
{
"version": 2,
"builds": [
{
"src": "dist/index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "dist/index.js"
}
]
}
Since you are using the builds
vercel.json
option, you need to ensure all the dependencies, like the compiled dist
folder and the node_modules
are uploaded.
Upvotes: 0
Reputation: 1801
Vercel is a static-first platform. You can't lift a server inside the platform and for that reason, it is not possible to use a classic "listen" approach.
Take a look at vercel.com/new and also a few examples.
Upvotes: 0