在 MacBook Pro M1 芯片上运行npm run dev
( gatsby develop
) 并退出 Error: Something went wrong installing the "sharp" module
运行npm run dev
MacBook Pro 英特尔芯片工作正常。
我看过类似的帖子,但没有解决我的问题:
我已经更新了我的节点版本,以防进行任何修复,但仍然出现错误node v16.0.0
在这个github 问题上,他们建议遵循这些不起作用的步骤。
Run Code Online (Sandbox Code Playgroud)rm -r node_modules/sharp yarn install --check-files
在这个github 问题上,他们建议安装NVM
和降级节点版本。NVM 在我的 M1 芯片上安装有一些困难,所以它对我来说不是一个好的选择。
我也尝试过执行以下步骤,但效果不佳
rm -rf node_module
rm package-lock.json
npm i
Run Code Online (Sandbox Code Playgroud)
知道如何修复gatsby develop
M1 芯片吗?
我正在使用锐利来调整大部分图像的大小。因此,我通过保留其纵横比将它们的大小调整为 500px。另外,我想将高度调整为 500px,如果高度大于宽度,则自动调整宽度,反之亦然。为此,我需要从图像缓冲区获取图像高度。我知道有相当多的软件包可以做到这一点。但我希望我是否可以使用锐利缓冲区本身来做到这一点。
我expo
在执行命令后尝试安装,exp start
但我得到:
Something went wrong installing the "sharp" module
Cannot find module '../build/Release/sharp.node'.
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我正在尝试在 Ubuntu 16.04 LTS 上安装Sharp。
我原本没有vips,所以我安装了
sudo apt-get install libvips-dev
Run Code Online (Sandbox Code Playgroud)
这修复了第一个错误,但现在我遇到了另一个错误:
In file included from ../src/common.cc:25:0:
/usr/include/vips/vips8:35:25: fatal error: glib-object.h: No such file or directory
compilation terminated.
sharp.target.mk:115: recipe for target 'Release/obj.target/sharp/src/common.o' failed
make: *** [Release/obj.target/sharp/src/common.o] Error 1
make: Leaving directory '/home/rachel/node_modules/sharp/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:269:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) …
Run Code Online (Sandbox Code Playgroud) 当尝试在 AWS Lambda 函数内运行时,我不断收到以下错误:
darwin-x64' 二进制文件不能在 'linux-x64' 平台上使用。请删除“node_modules/sharp/vendor”目录并运行“npm install”
我使用 MacBook Pro 中的无服务器框架部署了无服务器应用程序。我该如何解决这个问题?
我需要使用锐利。它在我的工作区工作正常,但如果我通过 docker 部署,则会出现错误。我正在执行所有步骤。
Error: 'linux-x64' binaries cannot be used on the 'linuxmusl-x64' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'linuxmusl-x64' platform.
Run Code Online (Sandbox Code Playgroud)
我认为 Sharp 是在第一次安装时预先构建的。它使用了我的计算机的架构(darwin,arm)但是当它在docker上运行时,虽然它再次构建,但该工作谈论的是我的计算机的架构。
我尝试删除工作区中的 node_modules 文件夹。- 在运行的 docker 上找不到 npm install 的纱线 pm2。- 权限问题
我的 Dockerfile:
FROM node:alpine
RUN mkdir -p /usr/src/node-app && chown -R node:node /usr/src/node-app
WORKDIR /usr/src/node-app
COPY package.json yarn.lock ./
USER node
RUN npm install --pure-lockfile
RUN npm install sharp --ignore-scripts=false
COPY --chown=node:node . .
EXPOSE 3050 …
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个esbuild
使用 Sharp 将 GIF 转换为 PNG 的插件,但出现以下错误:
\n\n\xe2\x9d\xaf npx esbuild .\\src\\utils\\gif-to-png.ts --platform=node --bundle\nnode_modules/sharp/lib/utility.js:7:22:错误:否加载器配置为“.node”文件:node_modules/sharp/build/Release/sharp.node\n7 \xe2\x94\x82 const Sharp = require(\'../build/Release/sharp.node\'); \n\xe2\x95\xb5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\n
import fs from \'fs\'\nimport path from \'path\'\nimport sharp from \'sharp\'\nimport { Plugin } from \'esbuild\'\n\nconst ROOT_PATH = process.cwd()\nconst POSTS_PATH = path.join(ROOT_PATH, \'public\')\n\nfunction* walkSync(dir: fs.PathLike): any {\n const files = fs.readdirSync(dir, { withFileTypes: true })\n for (let i = 0; i < files.length; i++) {\n if (files[i].isDirectory()) {\n yield* walkSync(path.join(dir as …
Run Code Online (Sandbox Code Playgroud) 我正在尝试对节点中的图像进行下采样.我将该图像存储为base64编码的字符串(即:"data:image/png; base64,iVBOR"等).我正在使用Sharp npm包.该文档似乎描述了锐利可以将文件路径带到图像或"inputBuffer".我做了一些谷歌搜索并假设Buffer类是他们所指的.连续尝试下面的代码导致我收到以下错误:"输入缓冲区包含不受支持的图像格式." 我的问题可能是什么,如果你不确定,请你推荐一个不同的npm包,文件更清晰?
const downsizeProfileImgForTweet = (user, cb) => {
let imgBuffer = Buffer.from(user.profileImg, 'base64');
sharp(imgBuffer)
.resize(52, 52)
.toBuffer()
.then(data => {
console.log("success");
user.profileImg = data;
cb()
} )
.catch( err => console.log(`downisze issue ${err}`) );
}
Run Code Online (Sandbox Code Playgroud)
我浏览了整个互联网并做了一堆猜测和检查,所以请原谅我的noob问题.提前感谢您提供的任何帮助!
对于node.js 使用清晰图像调整大小库https://github.com/lovell/sharp时,图像正在旋转.
我没有代码说.rotate(),为什么它被旋转,我怎么能阻止它旋转?
我使用的是由AWS提供的无服务器,图像缩放例如: https://github.com/awslabs/serverless-image-resizing使用拉姆达在飞行中调整图像如果缩略图不存在
S3.getObject({Bucket: BUCKET, Key: originalKey}).promise()
.then(data => Sharp(data.Body)
.resize(width, height)
.toFormat('png')
.toBuffer()
)
.then(buffer => S3.putObject({
Body: buffer,
Bucket: BUCKET,
ContentType: 'image/png',
Key: key,
}).promise()
)
.then(() => callback(null, {
statusCode: '301',
headers: {'location': `${URL}/${key}`},
body: '',
})
)
.catch(err => callback(err))
Run Code Online (Sandbox Code Playgroud)
原始大图:
已调整大小的图片:请注意它已被旋转:
我通过下载图像request
,然后通过 处理图像sharp
。但是有一个错误,输入文件丢失,实际上变量body
有一个值。
import { IADLandingPageABTest } from '@byted/ec-types';
import request from 'request';
import sharp from 'sharp';
const images: Array<keyof IADLandingPageABTest> = ['topPosterUrl', 'bottomPosterUrl'];
export default function handleImage (config: IADLandingPageABTest) {
images.forEach(key => {
const url = config[key];
if (url && typeof url === 'string' ) {
request(url, (err, response, body) => {
//console.log('body', body);
//body has a value
if (!err && response.statusCode === 200) {
sharp(body)
.resize(100)
.toBuffer()
.then((data) => {
console.log(data.toString('base64'));
})
.catch( …
Run Code Online (Sandbox Code Playgroud) sharp ×10
node.js ×7
aws-lambda ×2
javascript ×2
npm ×2
amazon-s3 ×1
apple-m1 ×1
base64 ×1
buffer ×1
docker ×1
esbuild ×1
expo ×1
express ×1
glib ×1
macos-mojave ×1
npm-install ×1
react-native ×1
request ×1
ubuntu ×1
vips ×1