NPM ошибка ERR! Error: EACCES: permission denied, rename
развернул LEMP на Ubuntu ~20.04.1, поставил NVM, через него поставил NPM, Composer, установил Laravel, выполнил миграцию, сменил владельца и группу для всех файлов проекта
$ sudo chown -R www-data:www-data /var/www/lara1.local
настроил хост в NGINX, прописал в /etc/hosts резолв, сайт открылся в браузере (тут вроде все ок).
И тут я вспоминаю что нужно в корне проекта выполнить (кстати зачем?)
$ npm i
Пробую и получаю ошибку:
toorr2p@srv1:/var/www/lara1.local$ npm i
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /var/www/lara1.local/node_modules/axios
npm ERR! dest /var/www/lara1.local/node_modules/.axios-9HH0Je4B
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/var/www/lara1.local/node_modules/axios' -> '/var/www/lara1.local/node_modules/.axios-9HH0Je4B'
npm ERR! [Error: EACCES: permission denied, rename '/var/www/lara1.local/node_modules/axios' -> '/var/www/lara1.local/node_modules/.axios-9HH0Je4B'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/var/www/lara1.local/node_modules/axios',
npm ERR! dest: '/var/www/lara1.local/node_modules/.axios-9HH0Je4B'
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: /home/toorr2p/.npm/_logs/2023-08-26T22_52_07_490Z-debug-0.log
Подскажите как ее решить? Что не так вообще с правами, как сделать что бы NPM выполнялся от www-data или из под root через sudo если у ж на то пошло?
Или в чем тут дело вообще?
P/S в первый раз ставлю Laravel
Источник: Stack Overflow на русском