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

[BUG] Cannot upgrade to NPM 8 because npm is trying to chown my antivirus #4158

Closed
matyasf opened this issue Dec 10, 2021 · 12 comments
Closed
Labels
Bug thing that needs fixing cmd:install related to `npm install` Release 8.x work is associated with a specific npm 8 release

Comments

@matyasf
Copy link

matyasf commented Dec 10, 2021

When I try to upgrade npm via the suggested method in the console:

npm install -g [email protected]

it fails with the following error:

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR!  [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/local/lib/node_modules/npm',
npm ERR!   dest: '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! }
npm ERR! 

When I try to run it with sudo:

npm ERR! code EPERM
npm ERR! syscall lchown
npm ERR! path /usr/local/bin/sentinelctl
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, lchown '/usr/local/bin/sentinelctl'
npm ERR!  [Error: EPERM: operation not permitted, lchown '/usr/local/bin/sentinelctl'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lchown',
npm ERR!   path: '/usr/local/bin/sentinelctl'
npm ERR! }

sentinelctl is control panel for Sentinel One antivirus, I guess its one of their security measures to make it not chown-able.

OS: OSX 11.6.1

npm --version
7.20.3

@EduApps-CDG
Copy link

EduApps-CDG commented Dec 11, 2021

Try with sudo su

Sometimes just sudo doesnt work.

Example:

[eduardo]:/$ sudo sync; sudo echo 1 > /proc/sys/vm/drop_caches
[sudo] password for eduardo: 
bash: /proc/sys/vm/drop_caches: Permission denied

Example 2:

[eduardo]:/$ sudo su
[root]:/# sync; echo 1 > /proc/sys/vm/drop_caches

@tomer-1
Copy link

tomer-1 commented Dec 21, 2021

i'm having the same problem,
doing the above solutions doesn't work.

ip-192-168-200-10:~ root# npm install -g npm
npm ERR! code EPERM
npm ERR! syscall lchown
npm ERR! path /usr/local/bin/sentinelctl
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, lchown '/usr/local/bin/sentinelctl'
npm ERR!  [Error: EPERM: operation not permitted, lchown '/usr/local/bin/sentinelctl'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lchown',
npm ERR!   path: '/usr/local/bin/sentinelctl'
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!     /var/root/.npm/_logs/2021-12-21T12_04_47_224Z-debug.log
ip-192-168-200-10:~ root# 

i really need help with that since i'm unable to upgrade npm

OS is macOS: 11.2.3
npm version: 8.1.2

@rvaibhav
Copy link

Facing the same problem.
Watching this thread for solutions!

sh-3.2# npm install -g [email protected]
npm notice 
npm notice New major version of npm available! 7.22.0 -> 8.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.3.0
npm notice Run npm install -g [email protected] to update!
npm notice 
npm ERR! code EPERM
npm ERR! syscall lchown
npm ERR! path /usr/local/bin/sentinelctl
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, lchown '/usr/local/bin/sentinelctl'
npm ERR!  [Error: EPERM: operation not permitted, lchown '/usr/local/bin/sentinelctl'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lchown',
npm ERR!   path: '/usr/local/bin/sentinelctl'
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!     /var/root/.npm/_logs/2021-12-29T15_57_07_920Z-debug.log
sh-3.2# whoami
root

@matyasf
Copy link
Author

matyasf commented Dec 29, 2021

I've managed to solve it by uninstalling and reinstalling node that upgraded npm.

@darcyclarke darcyclarke added Bug thing that needs fixing cmd:install related to `npm install` Release 8.x work is associated with a specific npm 8 release labels Jan 11, 2022
@lvliangxiong
Copy link

Facing the same problem. Watching this thread for solutions!

sh-3.2# npm install -g [email protected]
npm notice 
npm notice New major version of npm available! 7.22.0 -> 8.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.3.0
npm notice Run npm install -g [email protected] to update!
npm notice 
npm ERR! code EPERM
npm ERR! syscall lchown
npm ERR! path /usr/local/bin/sentinelctl
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, lchown '/usr/local/bin/sentinelctl'
npm ERR!  [Error: EPERM: operation not permitted, lchown '/usr/local/bin/sentinelctl'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lchown',
npm ERR!   path: '/usr/local/bin/sentinelctl'
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!     /var/root/.npm/_logs/2021-12-29T15_57_07_920Z-debug.log
sh-3.2# whoami
root

same issue

@For-chain
Copy link

When I install truffle, I also meet this problem. I can't solve it directly, so I install the package local and set the global variable.

cd /Users/user/Desktop/smart-contract
npm install truffle

It installed successfully in my local directory. Then set the global variable.

vim ~/.zsh_profile
And add: export PATH=/Users/user/Desktop/smart-contract/node_modules/.bin:$PATH
source ~/.zsh_profile

I think the effect is same with 'npm install truffle -g'

@svalluru
Copy link

svalluru commented Jan 31, 2022

Facing same issue. Any workaround ?

@dhmoore
Copy link

dhmoore commented Feb 1, 2022

why is npm trying to change ownership of files it didn't install?

@svalluru
Copy link

svalluru commented Feb 1, 2022

Got it working.

This problem occurs when angular is installed in global mode using the “-g” option.

Workaround :

install angular/cli in local mode using "sudo npm install @angular/cli"
then to run a locally installed version of the angular-cli, you can call ng commands directly by adding the .bin folder within your local node_modules folder to your PATH. The node_modules and .bin folders are created in the directory where npm install @angular/cli was run upon completion of the install command. Alternatively, you can install npx and run npx ng within the local directory where npm install @angular/cli was run, which will use the locally installed angular-cli.

@ljharb
Copy link
Contributor

ljharb commented Feb 1, 2022

@svalluru 1000% do NOT install anything locally with sudo. sudo should be avoided in general, but especially when it's not needed.

@wraithgar
Copy link
Member

Closing as a duplicate of #4010

@wraithgar
Copy link
Member

There is an rrfc open for this npm/rfcs#546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing cmd:install related to `npm install` Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests