lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.05k stars 1.29k forks source link

how can use sharp in lambda function (OS: window10 , severless) #1671

Closed kunka7 closed 5 years ago

kunka7 commented 5 years ago
module initialization error: Error
at Object.hasVendoredLibvips (/var/task/node_modules/sharp/lib/libvips.js:61:13)
at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:9:22)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/var/task/node_modules/sharp/lib/index.js:3:15)

how can fix this error? im already try this http://sharp.pixelplumbing.com/en/stable/install/#aws-lambda and failed

info sharp Using cached C:\Users\kimjs\AppData\Roaming\npm-cache\_libvips\libvips-8.7.4-linux-x64.tar.gz
ERR! sharp EPERM: operation not permitted, symlink 'libpng16\pnglibconf.h' -> 'C:\Users\kimjs\OneDrive\바탕 화면\picpledynamo\dynamo\node_modules\sharp\vendor\include\pnglibconf.h'
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies

C:\Users\kimjs\OneDrive\바탕 화면\picpledynamo\dynamo\node_modules\sharp>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\kimjs\OneDrive\바탕 화면\picpledynamo\dynamo\node_modules\sharp
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN dynamo@1.0.0 No description
npm WARN dynamo@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.22.1 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.22.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\kimjs\AppData\Roaming\npm-cache\_logs\2019-04-26T07_20_14_387Z-debug.log
lovell commented 5 years ago

Hi, the EPERM: operation not permitted, symlink message suggests you're installing to a FAT32 drive/folder, which doesn't support symlinks.

Did you try the Docker-based approach? https://sharp.pixelplumbing.com/en/stable/install/#aws-lambda

kunka7 commented 5 years ago

is docker work in window?

lovell commented 5 years ago

https://docs.docker.com/docker-for-windows/

kunka7 commented 5 years ago

i solved cmd need root access

djou-13 commented 4 years ago

i solved cmd need root access

You saved my life :-)

Tiffastic commented 3 years ago

Run the cmd as Admin solved my problem.

andresmv94 commented 2 years ago

In my case was the antivirus !!

ljmotta commented 9 months ago

I've came across this issue while installing the dependencies of my project, and I solved it by adding my user to the Create symbolic links policy.

I'm using Windows 11 Pro:

thanhnha121 commented 9 months ago

I've came across this issue while installing the dependencies of my project, and I solved it by adding my user to the Create symbolic links policy.

I'm using Windows 11 Pro:

  • Open the Local Security Policy -> Local Policies -> User Rights Assignment -> Create symbolic links
  • Click into Add User or Group...
  • Click into Advanced...
  • Click into Find Now
  • Search for your user and click all Oks... reboot your Windows.
  • Voilà

Worked for me, thanks @ljmotta

frostbitten commented 8 months ago

I've came across this issue while installing the dependencies of my project, and I solved it by adding my user to the Create symbolic links policy.

I'm using Windows 11 Pro:

  • Open the Local Security Policy -> Local Policies -> User Rights Assignment -> Create symbolic links
  • Click into Add User or Group...
  • Click into Advanced...
  • Click into Find Now
  • Search for your user and click all Oks... reboot your Windows.
  • Voilà

Thank you! I did not want to run things as administrator. This worked for me on Windows 10 HOME. Since I'm not on PRO, I had to enable the gpedit.msc feature with this (thankfully human-readable) copypasta: https://gist.github.com/lelegard/8da0b20cc35708852c14fcf899651204

lovell commented 8 months ago

The method of installation for prebuilt binaries has changed completely from sharp v0.33.0+ and this problem should go away entirely - more details at https://github.com/lovell/sharp/issues/3750