Installing Next.js in ispmanager 6
Why?
To install the Next.js framework and perform initial configuration to ensure it functions correctly within the panel.
Instructions
Prior to installing the Next.js framework, it is necessary to install Node.js via the panel and install the site handler in accordance with the instructions set out in the official guide.
Next.js requires Node.js version 18.17 or higher. By default, Node.js applications run over a port, so it's necessary to select "Port" in the "Connection Method" field.
Once the handler for the site has been installed, the next step is to install the packages for the framework. To complete this process, navigate to the Site menu (the "three dots" button) and select "View Node.js packages." Choose "Install" and specify the following packages in the "Node.js package name" field separated with a space:
next@latest
react@latest
react-dom@latest
Once the panel has completed the installation of the packages, it is necessary to modify the Node.js handler configuration file. To do so, navigate to the "Sites" section and select the desired site. Then, click on the "Configuration files" button.
Add the following lines to the “scripts” section of the Node.js configuration file:
“build" : "next build"
"dev" : "next dev"
"lint" : "next lint"
It's also necessary to specify a new parameter value next start
for the start
parameter. Here's an example:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
After making changes to the configuration file, it is necessary to create a directory in the root directory of the site where the application will be deployed. The default directory is "app".
Depending on your project, the application can also be configured to operate in the "pages" directory (instead of "app") and utilize the "public" directory for static files (images, fonts, etc.).
If following a configuration change Node.js starts with an error, open the shell client under the user-owner of the site in the site menu (the "three dots" button) and enter the command npm run build
.
Next, restart Node.js on the site by clicking on the “Restart (Node.js)” button in the site menu.
For further customization of the project, refer to the official Next.js documentation.