gpt4 book ai didi

node.js - npm安装错误: EACCES: permission denied,访问 '/var/www/html'

转载 作者:太空宇宙 更新时间:2023-11-04 00:05:15 24 4
gpt4 key购买 nike

我尝试在生产环境中运行 npm install 但出现错误

npm ERR! path /var/www/html
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/var/www/html'
npm ERR! { [Error: EACCES: permission denied, access '/var/www/html']
npm ERR! stack: 'Error: EACCES: permission denied, access \'/var/www/html\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/var/www/html' }
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 (though this is not recommended).

/var/www/html 是我在服务器中的网站目录。

我已经尝试过this ,仍然出现错误。

有什么想法吗?

最佳答案

感谢robrogers3,我得到了解决方案和@IftekharDani

完整解决方案:

  1. 向安装用户 (npm) 授予 /var/www/html 目录的权限:

    sudo chown -R $USER/var/www/html

  2. 授予网络服务器对 /var/www/html/storage/framework 目录的权限:

    sudo chown -R www-data:www-data/var/www/html/storage/framework

关于node.js - npm安装错误: EACCES: permission denied,访问 '/var/www/html',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52621963/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com