无法在 AWS Lambda 中使用 Sharp

问题描述 投票:0回答:1

我用

npm install --os=linux --cpu=x64 sharp
下载sharp:^0.33.2,提交放大后,说:

 "Could not load the \"sharp\" module using the linux-x64 runtime\nPossible solutions:\n- Ensure optional dependencies can be installed:\n    npm install --include=optional sharp\n    yarn add sharp --ignore-engines\n- Ensure your package manager supports multi-platform installation:\n    See https://sharp.pixelplumbing.com/install#cross-platform\n- Add platform-specific dependencies:\n    npm install --os=linux --cpu=x64 sharp\n- Consult the installation documentation:\n    See https://sharp.pixelplumbing.com/install"

我尝试了

0.33.0
0.33.1
,得到了同样的错误。

我尝试使用0.32.6,收到错误消息:

    Packaging lambda function failed with the error 
Command failed with exit code 1: yarn --no-bin-links --production
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.      
error E:\workplace\vscode\Quote-generator-aws-amplify-fullstack\amplify\backend\function\quoteLambda\src\node_modules\sharp: Command failed.Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
Arguments: 
Directory: E:\workplace\vscode\Quote-generator-aws-amplify-fullstack\amplify\backend\function\quoteLambda\src\node_modules\sharp
Output:
sharp: Using cached D:\nodejs\node_cache\_libvips\libvips-8.14.5-win32-x64.tar.br
sharp: Integrity check passed for win32-x64
sharp: Creating E:\workplace\vscode\Quote-generator-aws-amplify-fullstack\amplify\backend\function\quoteLambda\src\node_modules\sharp\build\Release
sharp: Copying DLLs from E:\workplace\vscode\Quote-generator-aws-amplify-fullstack\amplify\backend\function\quoteLambda\src\node_modules\sharp\vendor\8.14.5\win32-x64\lib to E:\workplace\vscode\Quote-generator-aws-amplify-fullstack\amplify\backend\function\quoteLambda\src\node_modules\sharp\build\Release
'prebuild-install' is not recognized as an internal or external command,
operable program or batch file.

E:\workplace\vscode\Quote-generator-aws-amplify-fullstack\amplify\backend\function\quoteLambda\src\node_modules\sharp>if not defined npm_config_node_gyp (node "D:\nvm\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.8.4 found at "D:\python\python.exe"
gyp http GET https://nodejs.org/download/release/v18.17.0/node-v18.17.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v18.17.0/node-v18.17.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v18.17.0/SHASUMS256.txt
gyp http GET https://nodejs.org/download/release/v18.17.0/win-x86/node.lib
gyp http GET https://nodejs.org/download/release/v18.17.0/win-arm64/node.lib
gyp http GET https://nodejs.org/download/release/v18.17.0/win-x64/node.lib
gyp http 200 https://nodejs.org/download/release/v18.17.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v18.17.0/win-x64/node.lib
gyp http 200 https://nodejs.org/download/release/v18.17.0/win-x86/node.lib
gyp http 404 https://nodejs.org/download/release/v18.17.0/win-arm64/node.lib
gyp info find VS using VS2022 (17.7.34024.191) found at:
gyp info find VS "D:\vs2022\IDE"
gyp info find VS run with --verbose for detailed information
gyp info spawn D:\python\python.exe
gyp info spawn args [
gyp info spawn args   'D:\\nvm\\install\\v18.17.0\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'E:\\workplace\\vscode\\Quote-generator-aws-amplify-fullstack\\amplify\\backend\\function\\quoteLambda\\src\\node_modules\\sharp\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'D:\\nvm\\install\\v18.17.0\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Rachel Duan\\AppData\\Local\\node-gyp\\Cache\\18.17.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\Rachel Duan\\AppData\\Local\\node-gyp\\Cache\\18.17.0',
gyp info spawn args   '-Dnode_gyp_dir=D:\\nvm\\install\\v18.17.0\\node_modules\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\Rachel Duan\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\18.17.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=E:\\workplace\\vscode\\Quote-generator-aws-amplify-fullstack\\amplify\\backend\\function\\quoteLambda\\src\\node_modules\\sharp',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'E:\\workplace\\vscode\\Quote-generator-aws-amplify-fullstack\\amplify\\backend\\function\\quoteLambda\\src\\node_modules\\sharp\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn D:\vs2022\IDE\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]

D:\vs2022\IDE\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.22621.0 was not 
found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [E:\workplace\vscode\Quote-generator-aws-amplify-fullstack\amplify\backend\function\quoteLambda\src\node_modules\sharp\node-addon-api\nothing.vcxproj]
D:\vs2022\IDE\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.22621.0 was not 
found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [E:\workplace\vscode\Quote-generator-aws-amplify-fullstack\amplify\backend\function\quoteLambda\src\node_modules\sharp\build\libvips-cpp.vcxproj]
gyp ERR! build error 
gyp ERR! stack Error: `D:\vs2022\IDE\MSBuild\Current\Bin\MSBuild.exe` 
failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:\nvm\install\v18.17.0\node_modules\npm\node_modules\node-gyp\lib\build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "D:\\nvm\\nodejs\\node.exe" "D:\\nvm\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"       
gyp ERR! cwd E:\workplace\vscode\Quote-generator-aws-amplify-fullstack\amplify\backend\function\quoteLambda\src\node_modules\sharp
gyp ERR! node -v v18.17.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok
yarn install v1.22.22
$ npm install --arch=x64 --platform=linux sharp

up to date, audited 151 packages in 5s

15 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

我尝试使用节点18.17.0和节点21+,错误都是一样的。

node.js aws-lambda aws-amplify sharp
1个回答
0
投票

我最终没有解决这些问题,我使用了很多不同的版本,包括0.33.0、0.33.1、0.33,2、0.32.6和0.32.1,也尝试了推荐命令和脚本预安装。

所以我最终决定使用Jimp和svg2png包并成功了。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.