我正在尝试在生产环境中运行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,但仍然遇到错误。
有什么想法吗?
答案 0 :(得分:2)
感谢robrogers3和@IftekharDani
完整解决方案:
向/var/www/html
目录授予安装用户(npm)权限:
sudo chown -R $USER /var/www/html
将Web服务器权限授予/var/www/html/storage/framework
目录:
sudo chown -R www-data:www-data /var/www/html/storage/framework
答案 1 :(得分:0)
您可以重试:
sudo npm install
答案 2 :(得分:0)
我在Win 7上遇到了同样的问题。如前所述,它与文件权限有关。我在Homestead.yml中有这个
folders:
- map: ...
to: ...
options:
owner: "www-data"
group: "www-data"
mount_options: ["dmode=775,fmode=664"]
请注意“选项”键。默认情况下,它不显示,但是我试图用符号链接来解决另一个问题……一旦删除它,一切都会起作用。另外,我将--no-bin-links
与npm install
命令一起使用