Troubles encountered during PM2 installation on macOS: "warning [email protected]" or "error code EACCES"

For some reason, I cannot seem to get PM2 to work properly on my macOS system. Despite multiple attempts and trying different methods like using sudo and adjusting npm directory permissions, the 'pm2' command remains unrecognized.

Hello there,

I'm currently in the process of installing PM2 globally.

1. => npm i pm2 -g

=>

npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7207071b1632415c465c">[email protected]</a>: Please upgrade  to version 7 or higher. ** Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

changed 163 packages in 9s

13 packages are looking for funding run npm fund for details

2. After installing the latest version, I encountered the same error, so I switched to version 7 as per a Stack Overflow article.

=>

npm install <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="95e0e0fcf1d5a2bba5bba6">[email protected]</a> --force

=> npm i pm2 -g

Subsequently, I came across this issue.

=>

npm ERR! code EACCES

npm ERR! syscall rename

npm ERR! path /Users/luc/.npm-global/lib/node_modules/pm2

npm ERR! dest /Users/luc/.npm-global/lib/node_modules/.pm2-5OKUrFlt

npm ERR! Your cache folder contains root-owned files, due to a bug in

npm ERR! previous versions of npm which has since been addressed.

npm ERR! To permanently fix this problem, please run:

npm ERR!   sudo chown -R 501:20 "/Users/luc/.npm"

npm ERR! A complete log of this run can be found in:

/Users/luc/.npm/_logs/2024-02-26T09_02_35_358Z-debug-0.log

3.

=>

sudo chown -R 501:20 "/Users/luc/.npm
"

=> sudo npm install pm2 -g

=>

d <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e792928e83a7d4c9d3c9d7">[email protected]</a>: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

changed 163 packages in 8s

13 packages are looking for funding run npm fund for details

To sum up, despite my best efforts to install PM2 on my macOS system, I am still facing issues with the 'pm2' command not being recognized in the terminal. I have tried various methods, including using sudo, adjusting npm directory permissions, and reinstalling PM2, but the problem persists.

Can anyone provide effective solutions to overcome this problem?

Therefore, I seek assistance in understanding and resolving this PM2 installation challenge. Any advice or help would be highly appreciated.

Thank you in advance!

Answer №1

The issue has been successfully resolved

Reason :

I have pinpointed the root cause of my problem: it was version 21 of Node.js.

RESOLUTION :

To fix this, I initially attempted to install Node.js version 20, but realized that NVM was missing from my system.

I proceeded to install NVM, with detailed instructions available at: Formulae and NVM GitHub.

Next, I upgraded node to version 20 using the following command:

nvm install v20.11.1

Afterwards, I confirmed proper functionality by running:

pm2 --version

This explanation may prove helpful to others facing a similar issue.

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

Whenever I utilize UUID in the code, it crashes unexpectedly, but then miraculously functions properly afterward

const express = require('express'); const { uuid } = require('uuidv4'); const app = express(); app.use(express.json()) const projects = []; app.post('/projects', (req,res)=>{ const { title, owner } = req.body; ...

What is the purpose of utilizing the npm init command when starting a fresh project?

When I first started learning Front End Development, I began by working on simple projects with just three files: a JavaScript file, an HTML file, and a CSS file. Now, I've learned that in order to start any new project, I need to use the npm init com ...

NPM encounters a hang-up while trying to install packages with the message "loadRequestedDeps → netwo"

I'm experiencing issues with npm hanging when trying to install any package. I've tried the proxy config fix but haven't had any success. My setup includes NPM 3.3.9, OSX El Capitan, and Node v4.2.2. If you have any suggestions or solutions, ...

What could be causing my PowerShell to be undefined when running npm run dev?

I am currently working on a Vue project using Vite in Windows 11. Whenever I try to run "npm run dev" with PowerShell (which is vite --open --host), I encounter the following error:https://i.stack.imgur.com/LPSc0.png It seems like the path is showing as & ...

Error encountered during Atom execution - The command '/usr/bin/env: 'node' was not found in the directory

Just starting out with coding on Atom and I'm stuck dealing with the same error message every time I try to run my Javascript code. bash: line 1: node: command not found /usr/bin/env: ‘node’: No such file or directory I've searched for solu ...

Run a Powershell command remotely in the background

I am attempting to connect to a Windows machine using SSH and run a command in the background. When I directly run the following command from the terminal after establishing an SSH connection, it works: start PowerShell.exe -ExecutionPolicy Unrestricted I ...

Issue with memory leakage detected during compilation of Angular 12 application

My coworker and I are currently in the process of optimizing our Angular 12 application for our enterprise. The Issue: One major challenge we have encountered while developing our application is the continuous increase in memory usage each time the angul ...

Running npm install within the user's data directory

My goal is to set up a launch template in AWS with specific user data included: #!/bin/bash home=/home/ec2-user nodev='8.11.2' nvmv='0.33.11' #install node su - ec2-user -c "curl https://raw.githubusercontent.com/creationix/nvm/v ...

Using regular expressions in JavaScript, eliminate all characters preceding a specified final character

I am attempting to eliminate all text that precedes the last character in a Regex pattern. For example: rom.com/run/login.php Would turn into: login.php Can someone guide me on how to achieve this using JavaScript? I have limited experience with regul ...

Error Alert: Fatal issue encountered while utilizing a Java npm package

Currently in my Meteor application, I am utilizing the 'node-excel-api' npm package which has a dependency on the 'java' npm package. Upon starting up the Meteor server, I encountered the following error message: A critical error has b ...

Updating Python packages on macOS can be easily done by following a few

Every time I open Terminal, I keep receiving the following error message: /usr/local/lib/python3.5/site-packages/powerline/bindings/zsh/powerline.zsh:200: /usr/local/bin/powerline-config: bad interpreter: /usr/local/opt/python3/bin/python3.5: no such fi ...

Error: The function is not defined in React-Redux when attempting to use React Final Form

I am currently in the process of developing a store that manages login information. However, when I dispatch with the action, I encounter an error message in the console. Error TypeError: Object(...) is not a function at onSubmit (Login.js:66) at O ...

Is it necessary for my Parse Server app to be constantly running on my server?

Setting up a parse server on my own server is proving to be quite the challenge for me. As a newbie, I've managed to install everything I need (Node v7.8, NPM v4.4.4) on my Ubuntu 16.04 LTS machine. Following the example app for the parse server seeme ...

Tips for integrating frontend npm packages into your project

As a beginner in Node.js web development, I recently used ExpressGenerator to create a project with the ExpressJS framework. I'm now looking to integrate the FineUploader front-end JS library into my application, which is available as an NPM package. ...

Having trouble locating the express module in your node application?

I am facing an issue that I can't seem to pinpoint the cause of, even though everything should be functioning properly. According to npm, I have express installed: C:\Users\phucker\Desktop>node init.js module.js:340 throw err; ...

What are the best steps to follow when creating a new package within a lerna monorepo?

I have recently come into possession of a monorepo that contains a packages folder housing all the current packages. My goal is to include a new main package that is essential for my existing panel package, which is currently at version 0.34.0. Since I fre ...

Encountering an error while trying to create a React app with npm - module not

Despite having experience with creating numerous React projects, I am encountering an error that I have never seen before. In an attempt to resolve it, I have restarted my computer, cleared my npm cache, and even deleted my package-lock file before running ...

There seems to be a connection issue (ETIMEDOUT) when trying to create a React app using npm

Struggling to set up a react app with npx create-react-app my-app. Unfortunately, an error keeps popping up in the terminal: npm ERR! code ETIMEDOUT npm ERR! syscall connect npm ERR! errno ETIMEDOUT npm ERR! network request to https://registry.npmjs.org/cr ...

Sharing modules on npm offline

I am currently using TFS 2018 on-premise, operating offline without access to nuget.org. Our biggest challenge has been coordinating open-source npm packages within the development team. However, with TFS 201, I have found a potential solution by setting u ...

Installing a package from a private repository using a different package name with npm

I'm looking to incorporate a module from a private GitHub repository into my project. To achieve this, I will execute the command npm install git+https://[API-KEY]:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0b737c6e607 ...