skip to Main Content

I’m trying to start a NextJS application on my Node server using Plesk but it is not working. I activated NodeJS for my Plesk environment, and I was able to run npm install and npm build, but now, when I try to start the application, Plesk only shows “Please wait” and stays like that with no change, I have been waiting for more than 2 hours now, but I don’t get any results, no errors, nothing.

The only issue I can think of is that, according to what I could find, the Application startup file and the package.json file should be in the same directory, the root folder, but in my case this is not possible. I have my package.json in the root directory, but the startup file for NextJS, index.js, is inside the pages folder. I tested building and starting the app locally and everything works fine, I don’t understand why it’s not working with Plesk.

3

Answers


  1. Chosen as BEST ANSWER

    I was able to fix this after correcting the startup file, it should be "node_modules/.bin/next" and not "pages/index.js".

    Also when you start your app, Plesk will tell you to wait. Just check the site and make sure it is running, if it is, you can close Plesk.


  2. You might need to install Express in your Next.js

    You may refer to this repo fmi @ https://github.com/zeit/next.js/tree/canary/examples/custom-server-express

    If you’re referring to the package.json’s command we’ll have:

    • dev
    • build
    • start

    In Plesk’s Node Application extension.

    1. Website & Domains > “Your Domain” > Enable Node.js
    2. Simply set server.js as my Application Startup File.
    3. Ensure that all dependencies is installed using “Npm Install” helper.
    4. You must run build command before start command.

    Screenshot:
    enter image description here

    Helpful NPM/Plesk reference:

    Login or Signup to reply.
  3. If you’re having issues with directories, you can create a standalone build of your next.js app by editing the next.config.js file:

    module.exports = {
      output: 'standalone',
    }

    (See the documentation https://nextjs.org/docs/advanced-features/output-file-tracing)

    It will require a few other steps but at least all your files will be together.
    (See https://mytchall.dev/removing-the-build-folders-when-deploying-next-js-on-plesk/)

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