锐包 Heroku 部署问题
Sharp package Heroku deployment issue
我正在将我的 NodeJs 应用程序部署到 Heroku。没有问题 运行 本地带有 nodemon 的应用程序。
然而,当我尝试推送到 Heroku Master 时,似乎“sharp”包导致了问题:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > sharp@0.22.0 install
/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp
remote: > (node install/libvips && node install/dll-copy &&
prebuild-install) || (node-gyp rebuild && node install/dll-copy)
remote:
remote: info sharp Downloading
https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
remote:
/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp/install/libvips.js:86
remote: throw new Error(Status
${response.statusCode}
);
remote: ^
remote:
remote: Error: Status 403
remote: at
/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp/install/libvips.js:86:17
remote: at f
(/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/once/once.js:25:25)
remote: at ClientRequest.protocol.request.res
(/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/simple-get/index.js:63:5)
remote: at Object.onceWrapper (events.js:277:13)
remote: at ClientRequest.emit (events.js:189:13)
remote: at HTTPParser.parserOnIncomingClient [as
onIncoming] (_http_client.js:556:21)
remote: at HTTPParser.parserOnHeadersComplete
(_http_common.js:109:17)
remote: at TLSSocket.socketOnData (_http_client.js:442:20)
remote: at TLSSocket.emit (events.js:189:13)
remote: at addChunk (_stream_readable.js:284:12)
remote: make: Entering directory
'/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp/build'
remote: TOUCH Release/obj.target/libvips-cpp.stamp
remote: CXX(target) Release/obj.target/sharp/src/common.o
remote: ../src/common.cc:25:10: fatal error: vips/vips8: No
such file or directory
remote: #include
remote: ^~~~~~~~~~~~
remote: compilation terminated.
remote: sharp.target.mk:128: recipe for target
'Release/obj.target/sharp/src/common.o' failed
remote: make: *** [Release/obj.target/sharp/src/common.o] Error
1
remote: make: Leaving directory
'/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp/build'
更新:
这次尝试从 package.json 中删除 sharp 然后使用 npm install sharp works 重新添加它...我仍然不知道为什么。
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > sharp@0.22.0 install
/tmp/build_5c8d3b01594e0b86f9d3e0d372534414/node_modules/sharp
remote: > (node install/libvips && node install/dll-copy &&
prebuild-install) || (node-gyp rebuild && node install/dll-copy)
remote:
remote: info sharp Downloading
https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
remote: added 57 packages from 92 contributors and audited
20393 packages in 10.683s
remote: found 62 low severity vulnerabilities
remote: run npm audit fix
to fix them, or npm audit
for
details
remote:
remote: -----> Build
remote:
remote: -----> Caching build
remote: - node_modules
remote:
remote: -----> Pruning devDependencies
remote: removed 606 packages and audited 497 packages in 8.181s
remote: found 0 vulnerabilities
remote:
remote:
remote: -----> Build succeeded!
有很多人有这个问题,它与 libvips 有关,因为依赖本身并不敏锐。
关于github在this issue-comment问题解释:
The pre-built binaries of sharp are only guaranteed to work with the pre-built binaries of libvips.
If the download of a pre-built binary of libvips fails then sharp has to fall back to attempting to build itself from source.
http://sharp.pixelplumbing.com/en/stable/install/#pre-compiled-libvips-binaries provides information about serving the libvips binaries from a local URL.
下载失败的原因可能是缓存,或者如上述 github 链接问题中报告的下载损坏:
I had to manually remove the ~/.npm/_libvips/libvips-8.7.0-linux-x64.tar.gz
and try again. Seems to be downloaded a corrupted file.
这是一个有趣的讨论,涉及与 gatsby 相关的相同问题,即使问题已关闭(在发表任何评论之前),解决方案似乎还不存在:https://github.com/gatsbyjs/gatsby/issues/1754
但是,如果由于某种原因问题仅与下载有关,则可以像 manual 中解释的那样在本地部署 libvips:
Pre-compiled libvips binaries
This module will attempt to download a pre-compiled bundle of libvips
and its dependencies on Linux and Windows machines under either of
these conditions:
- If a global installation of libvips that meets the minimum version
requirement cannot be found;
- If
SHARP_IGNORE_GLOBAL_LIBVIPS
environment variable is set.
SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install sharp
Should you need to manually download and inspect these files,
you can do so via https://github.com/lovell/sharp-libvips/releases
Should you wish to install these from your own location, set the
sharp_dist_base_url
npm config option, e.g.
npm config set sharp_dist_base_url "https://hostname/path/"
npm install sharp
or set the SHARP_DIST_BASE_URL
environment variable, e.g.
SHARP_DIST_BASE_URL="https://hostname/path/" npm install sharp
to use https://hostname/path/libvips-x.y.z-platform.tar.gz
.
所以这是一些背景知识,我知道这不能真正被视为解决方案的答案:/
如果有人到达此处但没有找到答案 - 我的问题是我的项目使用的是 旧节点版本 (8.x)
解决方案 是安装旧版本的 sharp - 支持 8.x 的最新版本 - "sharp": "0.23.4"
我正在将我的 NodeJs 应用程序部署到 Heroku。没有问题 运行 本地带有 nodemon 的应用程序。
然而,当我尝试推送到 Heroku Master 时,似乎“sharp”包导致了问题:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > sharp@0.22.0 install /tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp
remote: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
remote:
remote: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
remote:
/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp/install/libvips.js:86remote: throw new Error(
Status ${response.statusCode}
);remote: ^
remote:
remote: Error: Status 403
remote: at /tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp/install/libvips.js:86:17
remote: at f (/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/once/once.js:25:25)
remote: at ClientRequest.protocol.request.res (/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/simple-get/index.js:63:5)
remote: at Object.onceWrapper (events.js:277:13)
remote: at ClientRequest.emit (events.js:189:13)
remote: at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
remote: at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
remote: at TLSSocket.socketOnData (_http_client.js:442:20)
remote: at TLSSocket.emit (events.js:189:13)
remote: at addChunk (_stream_readable.js:284:12)
remote: make: Entering directory '/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp/build'
remote: TOUCH Release/obj.target/libvips-cpp.stamp
remote: CXX(target) Release/obj.target/sharp/src/common.o
remote: ../src/common.cc:25:10: fatal error: vips/vips8: No such file or directory
remote: #include
remote: ^~~~~~~~~~~~
remote: compilation terminated.
remote: sharp.target.mk:128: recipe for target 'Release/obj.target/sharp/src/common.o' failed
remote: make: *** [Release/obj.target/sharp/src/common.o] Error 1
remote: make: Leaving directory '/tmp/build_4cfeda2379ea362c72ac083b57638cce/node_modules/sharp/build'
更新:
这次尝试从 package.json 中删除 sharp 然后使用 npm install sharp works 重新添加它...我仍然不知道为什么。
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > sharp@0.22.0 install /tmp/build_5c8d3b01594e0b86f9d3e0d372534414/node_modules/sharp
remote: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
remote:
remote: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
remote: added 57 packages from 92 contributors and audited 20393 packages in 10.683s
remote: found 62 low severity vulnerabilities
remote: run
npm audit fix
to fix them, ornpm audit
for detailsremote:
remote: -----> Build
remote:
remote: -----> Caching build
remote: - node_modules
remote:
remote: -----> Pruning devDependencies
remote: removed 606 packages and audited 497 packages in 8.181s
remote: found 0 vulnerabilities
remote:
remote:
remote: -----> Build succeeded!
有很多人有这个问题,它与 libvips 有关,因为依赖本身并不敏锐。
关于github在this issue-comment问题解释:
The pre-built binaries of sharp are only guaranteed to work with the pre-built binaries of libvips.
If the download of a pre-built binary of libvips fails then sharp has to fall back to attempting to build itself from source.
http://sharp.pixelplumbing.com/en/stable/install/#pre-compiled-libvips-binaries provides information about serving the libvips binaries from a local URL.
下载失败的原因可能是缓存,或者如上述 github 链接问题中报告的下载损坏:
I had to manually remove the
~/.npm/_libvips/libvips-8.7.0-linux-x64.tar.gz
and try again. Seems to be downloaded a corrupted file.
这是一个有趣的讨论,涉及与 gatsby 相关的相同问题,即使问题已关闭(在发表任何评论之前),解决方案似乎还不存在:https://github.com/gatsbyjs/gatsby/issues/1754
但是,如果由于某种原因问题仅与下载有关,则可以像 manual 中解释的那样在本地部署 libvips:
Pre-compiled libvips binaries
This module will attempt to download a pre-compiled bundle of libvips and its dependencies on Linux and Windows machines under either of these conditions:
- If a global installation of libvips that meets the minimum version
requirement cannot be found;- If
SHARP_IGNORE_GLOBAL_LIBVIPS
environment variable is set.SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install sharp
Should you need to manually download and inspect these files,
you can do so via https://github.com/lovell/sharp-libvips/releasesShould you wish to install these from your own location, set the
sharp_dist_base_url
npm config option, e.g.npm config set sharp_dist_base_url "https://hostname/path/" npm install sharp
or set the
SHARP_DIST_BASE_URL
environment variable, e.g.SHARP_DIST_BASE_URL="https://hostname/path/" npm install sharp
to use
https://hostname/path/libvips-x.y.z-platform.tar.gz
.
所以这是一些背景知识,我知道这不能真正被视为解决方案的答案:/
如果有人到达此处但没有找到答案 - 我的问题是我的项目使用的是 旧节点版本 (8.x)
解决方案 是安装旧版本的 sharp - 支持 8.x 的最新版本 - "sharp": "0.23.4"