skip to Main Content

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


  1. Chosen as BEST ANSWER

    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:

    import('./server/index.mjs');
    

    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.


  2. 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:

    enter image description here

    My app runs in a subdomain abc.my-url.de

    So my Document Root is abc.my-url.de/.output/public
    My Aplication Url is http://abc.my-url.de
    My Application Root is abc.my-url.de

    The .output dir is generated with yarn build

    For the first time I advise you to set the Application Mode to development 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:

    // !!! the ./ at the beginning is extremely important !!!
    import('./.output/server/index.mjs');
    

    My Application Startup File is app.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 to production.


    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search