Home > front end >  How to solve Error: EACCES: permission denied in pm2?
How to solve Error: EACCES: permission denied in pm2?

Time:04-08

I don't know why I encounter this error, when I run pm2 status:

kaitoSwift@kaito-MacBook-Pro school-sms2 % pm2 status
node:internal/fs/utils:344
    throw err;
    ^

Error: EACCES: permission denied, open '/Users/kaitoSwift/.pm2/pm2.log'
    at Object.openSync (node:fs:585:3)
    at module.exports.Client.launchDaemon (/usr/local/lib/node_modules/pm2/lib/Client.js:228:12)
    at /usr/local/lib/node_modules/pm2/lib/Client.js:104:10
    at /usr/local/lib/node_modules/pm2/lib/Client.js:321:14
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at listOnTimeout (node:internal/timers:528:9)
    at processTimers (node:internal/timers:502:7) {
  errno: -13,
  syscall: 'open',
  code: 'EACCES',
  path: '/Users/kaitoSwift/.pm2/pm2.log'
}

When I tried to download pm2 using npm install pm2 -g:

kevintrinidad@kaito-MacBook school-sms2 % npm install pm2 -g 
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/pm2
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/pm2'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/pm2'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/pm2'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kaitoSwift/.npm/_logs/2022-04-07T11_15_28_141Z-debug-0.log

CodePudding user response:

you need to run this in sudo and verify that you didn't have other process that run on the same port.

CodePudding user response:

For installing PM2, use this:

sudo npm install -g pm2

For the error with pm2 status it's the same try with:

sudo pm2 status

The error tell you that /Users/kaitoSwift/.pm2/pm2.log does not exists.

  • Related