我觉得这没用,因为我的难题已经在几个不同的线程中讨论过了,但没有任何效果.
我在AWS Elastic Beanstalk上部署了一个ExpressJS/node服务器.当我几周前第一次try 部署时,我无法让它运行,直到我最终意识到我的许多依赖项之一(一个叫做Sharp的惊人图像大小调整工具)正在 destruct 它.我卸载了它,并删除了它在服务器中的用法.一切都很好.但我真的需要它——当我在本地设备上运行服务器时,它工作得很好.
但当我重新安装和部署时,我会出现以下错误:
npm ERR! path /var/app/staging/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && 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: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! sharp: Installation error: EACCES: permission denied, mkdir '/root/.npm'
网络上的大多数答案都是将unsafe perm=true作为环境变量设置在名为的文件中.npmrc,使用.配置文件.向根用户授予写入权限的ebextensions...在谷歌上搜索任何与锋利而有弹性的豆茎有关的东西,或者我的具体错误,都会给我带来无尽的紫色链接.但什么都没起作用.
编辑:我没有继续努力让Sharp工作,而是找到了另一种叫做Jimp的工具.可能不如夏普强大,但我真的需要调整尺寸,它可以做到这一点,所以如果有人因为这个问题而发飙,请考虑省go 自己的头痛,然后 Select Jimp.