I’m trying to deploy a Nuxt 3 website on Plesk, compiled with yarn build. I therefore have the PUBLIC and SERVER folders, which I have on Plesk hosting.
I have the server.js file which is the following:
`const app = require(‘./.output/server/index.mjs’);
const http = require(‘http’);
http.createServer(app).listen(process.env.PORT);`
I can’t find a single guide for Nuxt 3, I need to start the application. From my understanding though, Phusion should start processes without launching a manual start command?
Thank you very much
2
Answers
I solved my problem, and it is way easier than I anticipated: What you need to do is simply create a server.js file, containing 1 line:
which is the file generated by nuxt3 in ./output/server/index.mjs.
That's all. I was definitely overcomplicating it coming from nuxt2, I hope it can save time to others.
The accepted answer is fine I guess but unfortunately was not the solution for me. I have a Plesk Obsidian with Phusion Passenger as the OP. Unfortunately I have no access to the logs and asking the provider is a pain in the ass.
My Plesk nodejs config looks like:
My app runs in a subdomain
abc.my-url.de
So my
Document Root
isabc.my-url.de/.output/public
My
Aplication Url
ishttp://abc.my-url.de
My
Application Root
isabc.my-url.de
The
.output
dir is generated withyarn build
For the first time I advise you to set the
Application Mode
todevelopment
because Phusion Passenger doesn’t tell you about errors otherwise.And here is what makes the app running in my case:
I had to create a
app.cjs
(the name doesn’t matter but the ending does) with the content:My
Application Startup File
isapp.cjs
and is placed in the root of the subdomain where also the.output
folder is generated.If your app is running, don’t forget to change the
Application Mode
toproduction
.The reason why I have to use a
cjs
file is not clear to me, because I do not know the nodejs settings of the provider and he is keeping it as a secret.And the reason why I have to add the
./
to the import path inside the app.cjs is (so I was told from the provider) because Phusion Passenger copies the app into a sandboxed folder where it then runs. This doesn’t explains it well but it’s all I got.