I've tried other solutions found here but none of them work for me, right now my start script is like this
"build": "tsc && vite build",
"start": "vite preview --host 0.0.0.0 --port $PORT",
when I run this I get this error
2022-12-01T02:51:01.843831+00:00 app[web.1]: sh: 1: vite: not found
I set NPM_CONFIG_PRODUCTION
to false
in order to avoid prune my devDependencies because vite is listed there, but I'm still receiving the same error
Additionally, I tried run a static server
"start": "node server.cjs",
and my server file is this
const express = require('express')
const serveStatic = require('serve-static')
const path = require('path')
const app = express()
//here we are configuring dist to serve app files
app.use('/', serveStatic(path.join(__dirname, '/dist')))
// this * route is to serve project on different page routes except root `/`
app.get(/.*/, function (req, res) {
res.sendFile(path.join(__dirname, '/dist/index.html'))
})
const port = process.env.PORT || 8000
app.listen(port)
console.log(`app is listening on port: ${port}`)
this worked for some minutes (a really few minutes, like 2,3 minutes) but then I get this
2022-12-01T02:38:39.725919+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2022-12-01T02:38:39.894915+00:00 heroku[web.1]: Process exited with status 143
do you know what could be the problem here or are there any better configuration to deploy a vite app in Heroku? any suggestion? thank you so much