Introduction

When deploying applications developed with Nuxt 3 and similar frameworks, I often use GitHub Pages, Netlify, AWS Amplify, and Serverless Framework + Lambda. However, this time I had the opportunity to deploy using a VPS, so this is a memo.

References

Specifically, I use Amazon Lightsail and pm2.

Creating an Amazon Lightsail Instance

Select the Node.js blueprint.

Also, since port 3000 is used, open the firewall for it.

pm2 Configuration

I referred to the following article.

https://it-evo.jp/blog/blog-70/

Installation

snupdmoisnustallpm2-g

Downloading and Building Nuxt 3

Download the sample program.

scguditb/ihctolnmoaenm/eibihttntapmsi:///github.com/nakamura196/nuxt3-pm2

Setup

cndpmnuixnts3t-aplml2

Build

nnppmmrruunnbpurielvdiew

You can verify the Nuxt 3 application at localhost:3000.

Starting with pm2

cvdi//hhoommee//bbiittnnaammii//ecosystem.config.js
m}oda}up]lpnceisww}e}esawxncaa,n.:mdesrttfuibvPNee:cticcosni:OOx[:_aphhletnRDp{mnt:_lPea{TEo'/oc:ooorr:_rdhde[pwlvyEteoes'tSlaI3Nsmm::.iyiln0Voeomn:t0:='/'''nlge0,bcmo]si:1r,'{ilau,:n0vptuxtkt0arns'p{sr0loat,u:u0:dmete,uir/ot,1c/'srr0tn,eu0iurte0oxvr,0nteu,'3re,-/pimn2d'e,x.mjs',

Start pm2 with the following command.

pm2start/home/bitnami/ecosystem.config.js

Daemonization

As a future TODO, as mentioned in the following article, placing pm2 under systemctl management is one consideration.

https://zenn.dev/ukkz/articles/c19541f75754c7#さらにデーモン化する

I would like to try this on another occasion.

Summary

I was able to deploy a Nuxt 3 application using pm2 on a VPS (Amazon Lightsail) environment. We hope this is helpful for deploying Nuxt 3 applications in non-serverless environments.