When trying to run npm start, I get the error:
Error: EACCES: permission denied, open '/root/.pm2/module_conf.json'
at Object.openSync (node:fs:582:3)
at Object.readFileSync (node:fs:450:35)
at Object.Configuration.getAllSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:299:26)
at Object.Configuration.getSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:270:30)
at new API (/usr/local/lib/node_modules/pm2/lib/API.js:117:44)
at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
/usr/local/lib/node_modules/pm2/node_modules/@pm2/agent/src/InteractorClient.js:58
if (stats.uid === 0) {
^
TypeError: Cannot read property 'uid' of undefined
at /usr/local/lib/node_modules/pm2/node_modules/@pm2/agent/src/InteractorClient.js:58:21
at FSReqCallback.oncomplete (node:fs:195:21)
the command in package.json looks like this
{
"scripts": {
"start": "pm2 start ./node_modules/laravel-echo-server/dist/index.js"
},
"dependencies": {
"laravel-echo-server": "^1.6.2",
"save": "^2.4.0"
}
}
But if I run the command in the terminal pm2 start ./node_modules/laravel-echo-server/dist/index.js it works fine
/app # pm2 start ./node_modules/laravel-echo-server/dist/index.js
[PM2] Starting /app/node_modules/laravel-echo-server/dist/index.js in fork_mode (1 instance)
[PM2] Done.
┌─────┬────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1 │ index │ default │ 1.6.2 │ fork │ 13626 │ 0s │ 0 │ online │ 0% │ 7.6mb │ root │ disabled │
│ 0 │ laravelEcho │ default │ 1.6.2 │ fork │ 13608 │ 1s │ 1207 │ online │ 0% │ 69.6mb │ root │ disabled │
└─────┴────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list is not synchronized with saved list. Type 'pm2 save' to synchronize.
After searching the internet for a solution to the problem, I saw a possible solution, but it didn't work for me either. This solution was to create an ecosystem.config.js file here is an example with this solution but it doesn't work either
package.json
{
"scripts": {
"start": "pm2 start ecosystem.config.js"
},
"dependencies": {
"laravel-echo-server": "^1.6.2",
"save": "^2.4.0"
}
}
ecosystem.config.js
module.exports = {
apps : [
{
name: "laravelEcho",
script: "./node_modules/laravel-echo-server/dist/index.js",
args : "start"
}
]
}
Perhaps this will help when looking for the problem, I am using Docker Dockerfile
FROM node:alpine
WORKDIR /app
RUN npm install pm2:2.9.2 -g && pm2 update
EXPOSE 8888
What could be the problem?