将 Node Js API REST 部署到 CPANEL 时如何修复二进制错误。(共享主机)

Raf*_*art 6 shared-hosting cpanel node.js dev-to-production npm

首先感谢您的帮助。

我有一个 Node js API REST,我使用 Express、fs 模块、sharp for images 和许多其他模块,在我的机器上一切正常,我想在几个月前购买的共享主机中测试这个 API。

我的文件夹中有我的应用程序,节点 js 从 CPANEL 创建应用程序识别我的 JSON 文件,当我单击 NPM INSTALL 时,出现以下错误:

npm WARN lifecycle The node binary used for scripts is /home/webfoqgo/nodevenv/server/12/bin/node but npm is using /opt/alt/alt-nodejs12/root/usr/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
ERR! sharp Use with glibc 2.12 requires manual installation of libvips >= 8.10.0
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
make: execvp: cc: Permission denied
make: *** [Release/obj.target/nothing/../node-addon-api/nothing.o] Error 127
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/opt/alt/alt-nodejs12/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 2.6.32-954.3.5.lve1.4.77.el6.x86_64
gyp ERR! command "/opt/alt/alt-nodejs12/root/usr/bin/node" "/opt/alt/alt-nodejs12/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/webfoqgo/nodevenv/server/12/lib/node_modules/sharp
gyp ERR! node -v v12.19.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm WARN building-backend@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.26.3 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sharp@0.26.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/webfoqgo/.npm/_logs/2021-01-27T20_32_15_794Z-debug.log
Run Code Online (Sandbox Code Playgroud)

我尝试了两件事:

1.- 我在项目根目录中创建了一个 .npmrc 文件,如下所示:

如果我这样做不正确,请告诉我

2.- 我从 package.json 中删除了 SHARP 依赖项——这使得 cpanel 中的 NPM INSTALL 过程顺利进行,没有错误,但我的项目中确实需要 Sharp,因此删除它对于生产来说不是一个可行的选择。

我检查过的链接: StackOverflow 问题。

有人遇到过这个吗?非常感谢。