Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install PM2 node #5691

Open
StefCoders opened this issue Oct 15, 2023 · 2 comments
Open

Can't install PM2 node #5691

StefCoders opened this issue Oct 15, 2023 · 2 comments

Comments

@StefCoders
Copy link

What's going wrong?

I cannot install PM2 (i am root).

How could we reproduce this issue?

I'm really not sure, I was installing shinobi and said PM2 - command not found

Supporting information

$ pm2 report
pi@raspberrypi:~ $ sudo npm i -g pm2
npm ERR! code EACCES
npm ERR! syscall connect
npm ERR! errno EACCES
npm ERR! FetchError: request to https://registry.npmjs.org/pm2 failed, reason: connect EACCES 2606:4700::6810:1f22:443
npm ERR!     at ClientRequest.<anonymous> (/usr/share/nodejs/minipass-fetch/lib/index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:513:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:496:9)
npm ERR!     at TLSSocket.emit (node:events:525:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR!  FetchError: request to https://registry.npmjs.org/pm2 failed, reason: connect EACCES 2606:4700::6810:1f22:443
npm ERR!     at ClientRequest.<anonymous> (/usr/share/nodejs/minipass-fetch/lib/index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:513:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:496:9)
npm ERR!     at TLSSocket.emit (node:events:525:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
npm ERR!   code: 'EACCES',
npm ERR!   errno: 'EACCES',
npm ERR!   syscall: 'connect',
npm ERR!   address: '2606:4700::6810:1f22',
npm ERR!   port: 443,
npm ERR!   type: 'system',
npm ERR!   requiredBy: '.'
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!     /root/.npm/_logs/2023-10-15T18_30_12_442Z-debug-0.log

pi@raspberrypi:~ $ sudo npm i -g pm2
npm ERR! code EACCES
npm ERR! syscall connect
npm ERR! errno EACCES
npm ERR! FetchError: request to https://registry.npmjs.org/pm2 failed, reason: connect EACCES 2606:4700::6810:1f22:443
npm ERR!     at ClientRequest.<anonymous> (/usr/share/nodejs/minipass-fetch/lib/index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:513:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:496:9)
npm ERR!     at TLSSocket.emit (node:events:525:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR!  FetchError: request to https://registry.npmjs.org/pm2 failed, reason: connect EACCES 2606:4700::6810:1f22:443
npm ERR!     at ClientRequest.<anonymous> (/usr/share/nodejs/minipass-fetch/lib/index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:513:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:496:9)
npm ERR!     at TLSSocket.emit (node:events:525:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
npm ERR!   code: 'EACCES',
npm ERR!   errno: 'EACCES',
npm ERR!   syscall: 'connect',
npm ERR!   address: '2606:4700::6810:1f22',
npm ERR!   port: 443,
npm ERR!   type: 'system',
npm ERR!   requiredBy: '.'
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!     /root/.npm/_logs/2023-10-15T18_30_12_442Z-debug-0.log
@danielrpgj31
Copy link

danielrpgj31 commented Oct 16, 2023

Hi @StefCoders, your problem is interesting.

Please send details:
a. Raspberry version
b. Operating System
c. Log file generated at finished execution. Example: 2023-10-15T18_30_12_442Z-debug-0.log

For now, try the procedure below.
Change the location where global packages are stored, so you don't need superuser privileges:

a. Create a directory for global npm packages in your home directory:
$ mkdir ~/.npm-global

b. Configure npm to use this directory for global packages:
$ npm config set prefix '~/.npm-global'

c. Add the following line to your shell profile (e.g., ~/.bashrc or ~/.zshrc):
$ export PATH = ~/.npm-global/bin:$PATH

d. Source your shell profile to apply the changes:
$ source ~/.bashrc

e. Now you should be able to install npm packages globally without using sudo:
$ npm install -g pm2

Please give feedback.
Regards

@BzenkoSergey
Copy link

@danielrpgj31 It helped, thanks a lot!

Small correction:
it should not have spaces between key and value
export PATH = ~/.npm-global/bin:$PATH
causes this error:
-bash: export: =': not a valid identifier`

correct command:
export PATH=~/.npm-global/bin:$PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants