I've developed simple nestjs rest services. Now I am planning to deploy my app. Please help me with efficient way of production deployment of nestjs app.
1) Checkout your project's repository on your server and run npm install
.
2) Run npm run build
which compiles your project to javascript:
rimraf dist && tsc -p tsconfig.build.json
3) Start your application with:
node dist/main.js
See this answer.
1) Add the file Procfile
to your project's root directory:
web: npm run start:prod
2) Add this line to your package.json
's scripts
:
"heroku-postbuild": "echo Skip builds on Heroku"
3) Set the port in your main.ts
(or in your ConfigService
)
await app.listen(process.env.PORT || 3000);