'Something went wrong installing the \"sharp\" on aws Lambda
I am trying to upload function with an image cropper dependency as an aws lambda. It works perfectly on my local machine(node v14.17.3), but fails with the following error when triggering it as a lambda fn.
"errorType":
"Error"
"errorMessage":
"\nSomething went wrong installing the \"sharp\" module\n\nCannot find module '../build/Release/sharp-linux-x64.node'\nRequire stack:\n- /var/task/node_modules/sharp/lib/sharp.js\n- /var/task/node_modules/sharp/lib/constructor.js\n- /var/task/node_modules/sharp/lib/index.js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js\n\nPossible solutions:\n- Install with the --verbose flag and look for errors: \"npm install --ignore-scripts=false --verbose sharp\"\n- Install for the current runtime: \"npm install --platform=linux --arch=x64 sharp\"\n- Consult the installation documentation: https://sharp.pixelplumbing.com/install"
"stack":
"Error: "
"Something went wrong installing the \"sharp\" module"
""
"Cannot find module '../build/Release/sharp-linux-x64.node'"
"Require stack:"
"- /var/task/node_modules/sharp/lib/sharp.js"
"- /var/task/node_modules/sharp/lib/constructor.js"
"- /var/task/node_modules/sharp/lib/index.js"
"- /var/task/index.js"
"- /var/runtime/UserFunction.js"
"- /var/runtime/index.js"
""
"Possible solutions:"
"- Install with the --verbose flag and look for errors: \"npm install --ignore-scripts=false --verbose sharp\""
"- Install for the current runtime: \"npm install --platform=linux --arch=x64 sharp\""
"- Consult the installation documentation: https://sharp.pixelplumbing.com/install"
" at Object.<anonymous> (/var/task/node_modules/sharp/lib/sharp.js:30:9)"
" at Module._compile (internal/modules/cjs/loader.js:1085:14)"
"
The js file name is index.js and I have zipped all the files below. All the file permissions are as follows:
-rw-r--r-- 1 ***** staff 1379 Dec 26 12:22 index.js
-rw-r--r-- 1 ***** staff 280 Dec 26 12:59 package.json
drwxr-xr-x 6 ***** staff 192 Dec 26 13:08 ..
-rw-r--r-- 1 ***** staff 44154 Dec 26 13:31 package-lock.json
drwxr-xr-x 69 ***** staff 2208 Dec 26 13:31 node_modules
I am not sure how to debug this issue as per the suggestions suggested by the error as the image cropper works fine on my local machine. The image cropper version is:
"node_modules/sharp": {
"version": "0.29.3",
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.29.3.tgz",
....
Any suggestions where am I going wrong?
Solution 1:[1]
To fix it on MAC, try this solution:
npm install --platform=linux --arch=x64 sharp
It worked for me.
Solution 2:[2]
As pointed by @TheMaster above, there is a typo on the method showAdminSidebar().
...SpreadsheetApp.getUI().showSidebar(widget);... where getUI() should be getUi().
See this documentation of methods the class SpreadsheetApp has.
Just tested here and it works just fine after fixing it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | NineCattoRules |
| Solution 2 |
