I'm trying to deploy a site to a Plesk server and unlike with previous Next JS versions where you had to edit /node_modules/.bin/next
file and add start
to const defaultCommand
.
(you can check reference here) https://medium.com/@keithchasen/how-to-set-up-your-next-js-app-on-plesk-server-7d8d247a2db2
I'm wondering if anyone of you know what would the hack for latest version of Next
Thanks in advance, NumaX
I tried this https://talk.plesk.com/threads/nextjs-works-on-plesk.354281/
I found a solution for Nextjs 14.2.5. Open and Edit the File in /node_modules/.bin/next
via the File Manager. In lines 81-83, there should be the code:
program.command("dev", {
isDefault: true
}).description("Starts Next.js in development mode with hot-code reloading, error reporting, and more.").argument("[directory]", `A
Set isDefault
to false
program.command("dev", {
isDefault: false
}).description("Starts Next.js in development mode with hot-code reloading, error reporting, and more.").argument("[directory]", `A
Then in In line 105, there should be the following code:
program.command("start").description("Starts Next.js in production mode. The application should be compiled with `next build` first.").argument("[directory]", `A directory on which to start the application. ${(0, _picocolors.italic)("If no directory is provided, the current directory will be used.")}`).addOption(new _commander.Option("-p, --port <port>", "Specify a port number on which to start the application.").argParser(_utils.myParseInt).default(3000).env("PORT")).option("-H, --hostname <hostname>", "Specify a hostname on which to start the application (default: 0.0.0.0).").addOption(new _commander.Option("--keepAliveTimeout <keepAliveTimeout>", "Specify the maximum amount of milliseconds to wait before closing inactive connections.").argParser(_utils.myParseInt)).action((directory, options)=>import("../cli/next-start.js").then((mod)=>mod.nextStart(options, directory))).usage("[directory] [options]");
Add an additional object argument with isDefault: true
program.command("start", {
isDefault: true
}).description("Starts Next.js in production mode. The application should be compiled with `next build`
Save and close the file, then go to nodejs. Run npm install
and npm build
and it should be working now.
IMPORTANT NOTE: When you have new updates to your project and would like to re-deploy your next app, first pull your project from your repository, then navigate to Node.js dev tool and restart it using the Restart App
button, and finally run npm install
and npm build
.
I hope Plesk would find a way to integrate Nextjs to its platform. At the moment it takes a lot of manual steps just to get it to work.