Ошибка прав доступа при npm install под рутом
При попытке выполнить npm install вываливается вот такая ошибка:
[root@ovz1 server]# npm i
npm ERR! code 1
npm ERR! path /var/www/server/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
npm ERR! sharp: Are you trying to install as a root or sudo user? Try again with the --unsafe-perm flag
npm ERR! sharp: Attempting to build from source via node-gyp but this may fail due to the above error
npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! make: Entering directory `/var/www/server/node_modules/sharp/build'
npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm ERR! make: Leaving directory `/var/www/server/node_modules/sharp/build'
npm ERR! sharp: EACCES: permission denied, mkdir '/root/.npm'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.6.8 found at "/usr/bin/python3"
npm ERR! gyp WARN EACCES current user ("apache") does not have permission to access the dev dir "/root/.cache/node-gyp/14.16.0"
// дальше еще лог ошибки на 20 строк
Интересует вот этот кусок gyp WARN EACCES current user ("apache") does not have permission
Почему оно упорно пишет, что текущий пользователь - "apache", хотя все запускается из под root.
Пробовал с флагом --unsafe-perm, не помогло
ОС - CentOS 7