Tips for resolving Error: EACCES - permission denied when using pm2

I'm stumped by this error that keeps popping up 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'
}

Another issue arises when attempting to install 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

Answer №1

If you encounter a permission issue while using pm2 on an Ubuntu server hosted on EC2 with error code EACCES :-13, don't worry! Just follow these simple steps to resolve it:

1. Switch to the root user permissions by running sudo su -
2. Create a file named ecosystem.config.js in the root directory:
   module.exports = {
     apps : [{
       name: "server",
       script: "server.js"
     }]
   }
3. Finally, execute the command pm2 start server

Answer №2

To install PM2, follow these steps:

sudo npm install -g pm2

If you encounter an error with pm2 status, try using this command instead:

sudo pm2 status

The error message indicates that the file /Users/kaitoSwift/.pm2/pm2.log does not exist.

Answer №3

Make sure to execute this with sudo privileges and double-check that there are no other processes using the same port.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Move the location of the npm-debug.log file

Whenever I initiate npm start and encounter an error, the following message is displayed: npm ERR! Additional logging details can be found in: npm ERR! /home/hsz/Projects/project/npm-debug.log npm ERR! not ok code 0 This file is located within the di ...

The benefits of implementing a package.json file in our Node project

What is the purpose of generating a package.json file with npm init and how does it play a role when we push our project to git? ...

Is compiling inline sass possible with npm?

Looking for a simple method to achieve this task? I've experimented with sass, node-sass, and tinysass without success. My goal is to compile inline sass in JavaScript, much like the code snippet below: import sassPkg from 'sass-pkg' const ...

Node.js and TestCafe encountered a critical error: Inefficient mark-compacts were performed near the heap limit, resulting in an allocation failure. The JavaScript heap ran

While executing my test scripts in Node v14.6.0, I encountered the following problem. Here are some of the options I've tried: I attempted to increase the Node Heap Size but unfortunately had no success: export NODE_OPTIONS=--max_old_space_size=4096 ...

Facing issues while trying to deploy my Angular 5 application on Heroku

I've encountered an issue while attempting to deploy my Angular 5 project on Heroku. While I've successfully deployed other projects before, this one seems to have a dependency problem that is hindering the process. Locally, running ng build pos ...

Error: npx is unable to locate the module named 'webpack'

I'm currently experimenting with a customized Webpack setup. I recently came across the suggestion to use npx webpack instead of node ./node_modules/webpack/bin/webpack.js. However, I am encountering some difficulties getting it to function as expecte ...

Utilizing Grunt to streamline a personalized project

I have set up Grunt as my "JS Task Runner". Node.js is installed in the directory "C:/Program Files". NPM has been installed in C:/users/Peterson/appdata/roaming/npm. Inside the npm folder, I have Grunt, Bower, and Grunt-cli. I am working on a pro ...

Utilize an npm package or Python script to convert a .3ds file to either .obj, .collada, or .g

I have a collection of .3ds format files that I need to convert into gltf format. Are there any tools available to directly convert them into either .gltf format or collada/.obj format? I have already explored npm packages for converting collada/.obj to g ...

Alternatives for handling npm errors stemming from package unpublish issues

Our current project is developed using node.js, and we are looking to organize its dependencies through npm's package.json file with designated versions for each dependency. But there is a concern about what happens if one of the packages our project ...

Can a condition be incorporated in a gulpfile to execute a task depending on the size of a file?

Currently, I am utilizing gulp for image compression. However, my requirement is to only compress images exceeding 200kb in size. Can JavaScript be used to loop through a directory and selectively run the minification process on files larger than 200kb? ...

Error in JavaScript with Laravel Mix/NPM.js: The variable twemoji.parse cannot be found or is undefined

Greetings everyone, Currently, I am using Laravel Mix to integrate Twemoji and other modules through Node. Unfortunately, I am encountering console errors indicating that the dependencies are not loading correctly. One example of this error is: TypeError ...

Should I include one of the dependencies' dependencies in my project, or should I directly install it into the root level of the project?

TL;DR Summary (Using Lodash as an example, my application needs to import JavaScript from an NPM package that relies on Lodash. To prevent bundling duplicate versions of the same function, I'm considering not installing Lodash in my application' ...

Encountering an issue when starting a Node.js/Swagger application using pm2 within a Docker environment: Unable to

1. Overview: I successfully developed a basic application using Node.js, Express, and Swagger by following this informative tutorial, along with the help of generator-express-no-stress. However, when I attempt to run the application within a Docker contai ...

React: Material UI causing an error due to an invalid hook call

Working on a React project using create-react-app with material UI, encountering errors like: https://i.stack.imgur.com/mhjkE.png Appears to be an internal issue with material UI once setting a custom theme. import { ThemeProvider } from "@mui/material/ ...

Get Bootstrap 5.0.0 Alpha 2 up and running by installing it through the package.json file

Currently listed in my package.json file are the following devDependencies: { "devDependencies": { "axios": "^0.19", "bootstrap": "^4.5.0", "cross-env": "^7.0", "laravel-mix": "^5.0.1", "lodash": "^4.17.19", ...

Get the JS file by tapping the download button, and access the

In creating the web page, I utilize a modular approach. Leveraging node js and the node-static server are essential components of this process. One specific requirement I have is implementing file downloads from a computer to a device using a button trigg ...

Having trouble executing a node module on a Windows system?

I am encountering an issue while trying to run npm run start-dev. I have been unable to resolve it on my own and could use some assistance. Here is a screenshot of the problem: https://i.stack.imgur.com/Qx243.png ...

npm installation encounters errors when a package is listed as a dependency

Currently, I am in the process of developing an npm package called libsbmlsim. This package is designed to install binaries that will be utilized server-side at a later point. During the installation process using npm install, everything works smoothly. H ...

Why are there so many modules being installed with `npm install` when I only need to install two?

Here is my package.json configuration: { "private": true, "devDependencies": { "gulp": "^3.9.0", "laravel-elixir": "*" "bootstrap-sass": "^3.0.0" } } After running npm install, I ended up with a whopping 800 modules ranging from "abbrev ...

Guide on launching an Angular 12 project with the help of Angular CLI 13

After downloading an Angular 12 project, I attempted to run it using Angular 13 (the latest version). However, I encountered issues when trying to run it. Even after attempting to use npm install, I still faced dependency problems. Errors occurred when ru ...