Dev./Node.js

[Sharp] Cannot find module '../build/Release/sharp-linux-arm64v8.node' 오류

인쥭 2023. 8. 10. 15:18
반응형

AWS Lambda에서 이미지 리사이징을 위해 sharp 라이브러리를 사용했을 때, 제목과 같은 오류가 발생할 수 있다.

이는 AWS Lambda의 아키텍쳐와 sharp 라이브러리의 아키텍쳐가 맞지 않기 때문에 발생하는 문제이며, 다음과 같이 node_modules에 sharp를 재설치하여 해결할 수 있다.

[~] rm -rf ./node_modules/sharp
[~] SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=arm64 --platform=linux sharp
[~]

참고

 

sharp - High performance Node.js image processing

 

sharp.pixelplumbing.com