我觉得这毫无用处,因为我的难题已在多个不同的线程中讨论过,但没有任何效果。
我有一个 ExpressJS/节点服务器部署到 AWS Elastic Beanstalk。当我几周前第一次尝试部署时,我无法让它运行,直到我最终意识到我的许多依赖项之一(一个名为 Sharp 的令人惊叹的图像调整工具)正在破坏它。我卸载了它并删除了它在服务器中的使用。一切都很好。但我确实需要它——当我在本地设备上运行服务器时,它工作得很好。
但是当我重新安装并部署时,出现以下错误:
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'
Run Code Online (Sandbox Code Playgroud)
网上的大多数答案都是在名为 .npmrc 的文件中设置 …