I was trying to build my nextjs website and got this error
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4048,
code: 'EPERM',
syscall: 'open', path: 'E:\\ECell Project\\ecell-uptodat\\ecell-main\\.next\\trace'
}
I am unable to figure out what is causing this error.
Error: ENOENT: no such file or directory, scandir './events/client/' at readdirSync (node:fs:1392:3) at loadcommand (/home/runner/test-5/handlers/loadEvent.js:7:24) at /home/runner/test-5/handlers/loadEvent.js:14:40 at Array.forEach () at module.exports (/home/runner/test-5/handlers/loadEvent.js:14:25) at /home/runner/test-5/nanospace.js:49:107 at Array.forEach () at new MainClient (/home/runner/test-5/nanospace.js:49:68) at Object. (/home/runner/test-5/index.js:2:16) at Module._compile (node:internal/modules/cjs/loader:1097:14) { errno: -2, syscall: 'scandir', code: 'ENOENT', path: './events/client/'
Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\Karan\AppData\Roaming\npm-cache_npx\7944\node_modules\create-react-app\node_modules'
at Object.rmdirSync (fs.js:769:3)
at rmkidsSync (C:\Users\Karan\AppData\Roaming\npm\node_modules\npm\node_modules\rimraf\rimraf.js:364:25)
at rmdirSync (C:\Users\Karan\AppData\Roaming\npm\node_modules\npm\node_modules\rimraf\rimraf.js:342:7)
at rimrafSync (C:\Users\Karan\AppData\Roaming\npm\node_modules\npm\node_modules\rimraf\rimraf.js:312:9)
at C:\Users\Karan\AppData\Roaming\npm\node_modules\npm\node_modules\rimraf\rimraf.js:350:5
at Array.forEach ()
at rmkidsSync (C:\Users\Karan\AppData\Roaming\npm\node_modules\npm\node_modules\rimraf\rimraf.js:349:26)
at rmdirSync (C:\Users\Karan\AppData\Roaming\npm\node_modules\npm\node_modules\rimraf\rimraf.js:342:7)
at rimrafSync (C:\Users\Karan\AppData\Roaming\npm\node_modules\npm\node_modules\rimraf\rimraf.js:312:9)
at C:\Users\Karan\AppData\Roaming\npm\node_modules\npm\node_modules\rimraf\rimraf.js:350:5 {
errno: -4051,
syscall: 'rmdir',
code: 'ENOTEMPTY',
path: 'C:\Users\Karan\AppData\Roaming\npm-cache\_npx\7944\node_modules\create-react-app\node_modules'
}
My current setup is nginx -> reverse proxy -> nextjs. I"m using pm2 with cluster mode for nextjs. The problem is after nextjs is up for like 10 mins, it's stop responding without a trace of error but this issue is resolved when I restart nextjs app with pm2 restart all. It looks like my nextjs app only live for 10 mins and after that I have to restart. So I have to run a cron job to do this.
pm2 log output
2020-01-14T09:40:02: PM2 log: App [npm:0] starting in -cluster mode-
2020-01-14T09:40:02: PM2 log: App [npm:0] online
2020-01-14T09:40:02: PM2 log: App [npm:1] starting in -cluster mode-
2020-01-14T09:40:02: PM2 log: App [npm:1] online
2020-01-14T09:40:02: PM2 log: App [npm:2] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:2] online
2020-01-14T09:40:03: PM2 log: App [npm:3] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:3] online
2020-01-14T09:40:03: PM2 log: App [npm:4] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:4] online
2020-01-14T09:40:03: PM2 log: App [npm:5] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:5] online
2020-01-14T09:40:03: PM2 log: App [npm:6] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:6] online
2020-01-14T09:40:03: PM2 log: App [npm:7] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:7] online
> Server started at http://localhost:3000 with development ? false
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
Though you did not mention using npm, I fixed a similar issue by removing usage of npm from the ecosystem.config.json file.
Before (not working):
{
"apps": [
{
...
"script": "/usr/bin/npm",
"args" : "start",
...
}
]
}
After (working):
{
"apps": [
{
...
"script": "./node_modules/.bin/next",
"args" : "start -p 3000",
...
}
]
}
I did not take time to dig into the issue with npm.
I found the solution here: express server port configuration issue with pm2 cluster mode
events.js:167
throw er; // Unhandled 'error' event
^
> Error: spawn C:\WINDOWS\system32\cmd.exe; ENOENT
> at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
> at onErrorNT (internal/child_process.js:407:16)
> at process._tickCallback (internal/process/next_tick.js:63:19)
> Emitted 'error' event at:
> at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
> at onErrorNT (internal/child_process.js:407:16)
> at process._tickCallback (internal/process/next_tick.js:63:19)