• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue Cannot run NextJS website ( Error: Cannot find module '../server/require-hook' )

yelnya

New Pleskian
Server operating system version
AlmaLinux 8
Plesk version and microupdate number
Plesk Obsidian Version 18.0.55 Update #2
I am unable to make NextJS ( "next": "13.1.1" / "next": "13.5.6" ) work with Plesk,
I have followed all the exact tutorial steps from: How to set up your NEXT.JS app on Plesk server

Here is my Node.js Dashboard Page:
Screenshot_33.png
Here is my node_modules/.bin/next file ( I changed const defaultCommand from "dev" to "start" )
Screenshot_35.png

Here is the result when I run "npm run build" ( Error: Cannot find module '../server/require-hook' ):

> [email protected] build
> next build


node:internal/modules/cjs/loader:1031
throw err;
^

Error: Cannot find module '../server/require-hook'
Require stack:
- /var/www/vhosts/chatty.asia/dashboard.chatty.asia/node_modules/.bin/next
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1028:15)
at Function.Module._load (node:internal/modules/cjs/loader:873:27)
at Module.require (node:internal/modules/cjs/loader:1100:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (/var/www/vhosts/chatty.asia/dashboard.chatty.asia/node_modules/.bin/next:6:1)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
at Module.load (node:internal/modules/cjs/loader:1076:32)
at Function.Module._load (node:internal/modules/cjs/loader:911:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/var/www/vhosts/chatty.asia/dashboard.chatty.asia/node_modules/.bin/next'
]
}

I have another NextJS domain ( "next": "12.1.0" ) and it is working perfectly fine but not for my new NextJS project ( "next": "13.1.1" / "next": "13.5.6" )

This is my "package.json" file:

{
"name": "nextjs_plesk_test",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"eslint": "8.52.0",
"eslint-config-next": "13.5.6",
"next": "13.5.6",
"react": "18.2.0",
"react-dom": "18.2.0"
}
}
 
i had the same problem, have you found the solutions for this TT.TT I did follow the instruction but I still have the same error
 
I have the same problem when editing files (e.g. package.json) with the Plesk file manager. When I do not open the file manager or any file with it and modifying the files via the command line, everything works fine.

I think it is some kind of file permission problem, but I do not know yet what exactly the problem is...
 
Back
Top