Install: multiple platform-arch binaries in same tree

This commit is contained in:
Lovell Fuller
2021-06-13 09:32:16 +01:00
parent 8c6d9fdc62
commit 6c2e6c5432
12 changed files with 51 additions and 79 deletions

View File

@@ -8,6 +8,9 @@ Requires libvips v8.11.0
* Drop support for Node.js 10, now requires Node.js >= 12.13.0.
* Allow multiple platform-arch binaries in same `node_modules` installation tree.
[#2575](https://github.com/lovell/sharp/issues/2575)
## v0.28 - *bijou*
Requires libvips v8.10.6

View File

@@ -206,32 +206,18 @@ to `false` when using the `yarn` package manager.
## AWS Lambda
The binaries in the `node_modules` directory of the
The `node_modules` directory of the
[deployment package](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html)
must be for the Linux x64 platform.
must include binaries for the Linux x64 platform.
When building your deployment package on machines other than Linux x64 (glibc),
run the following commands:
run the following additional command after `npm install`:
macOS:
```sh
rm -rf node_modules/sharp
npm install
SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=x64 --platform=linux sharp
```
Windows:
```sh
rmdir /s /q node_modules/sharp
npm install --arch=x64 --platform=linux sharp
```
Alternatively a Docker container closely matching the Lambda runtime can be used:
```sh
rm -rf node_modules/sharp
docker run -v "$PWD":/var/task lambci/lambda:build-nodejs12.x npm install sharp
```
To get the best performance select the largest memory available.
A 1536 MB function provides ~12x more CPU time than a 128 MB function.