strapi-community / strapi-plugin-local-image-sharp

Dynamically resize, format and optimize images based on url modifiers.
https://strapi-community.github.io/strapi-plugin-local-image-sharp/
64 stars 16 forks source link

Any plans to get this working with node 20.x? #39

Open frugan-dev opened 5 months ago

frugan-dev commented 5 months ago

If I try I get this:

node v20.11.0 npm v10.2.4

npm WARN deprecated ohmyfetch@0.4.21: Package renamed to https://github.com/unjs/ofetch
npm ERR! code 1
npm ERR! path /opt/app/node_modules/ipx/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm ERR! sharp: Detected globally-installed libvips v8.15.0
npm ERR! sharp: Building from source via node-gyp
npm ERR! 
npm ERR! make: Entering directory '/opt/app/node_modules/ipx/node_modules/sharp/build'
npm ERR!   CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm ERR! rm -f Release/obj.target/../node-addon-api/nothing.a Release/obj.target/../node-addon-api/nothing.a.ar-file-list; mkdir -p `dirname Release/obj.target/../node-addon-api/nothing.a`
npm ERR! ar crs Release/obj.target/../node-addon-api/nothing.a @Release/obj.target/../node-addon-api/nothing.a.ar-file-list
npm ERR!   COPY Release/nothing.a
npm ERR!   TOUCH Release/obj.target/libvips-cpp.stamp
npm ERR!   CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/common.o
npm ERR!   CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/metadata.o
npm ERR!   CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/stats.o
npm ERR!   CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/operations.o
npm ERR!   CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/pipeline.o
npm ERR! make: Leaving directory '/opt/app/node_modules/ipx/node_modules/sharp/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.11.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.11.6 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/app/node_modules/ipx/node_modules/sharp/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.cache/node-gyp/20.11.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/20.11.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/20.11.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/opt/app/node_modules/ipx/node_modules/sharp',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! ../src/pipeline.cc: In member function 'virtual void PipelineWorker::OnOK()':
npm ERR! ../src/pipeline.cc:1229:30: error: aggregate 'PipelineWorker::OnOK()::stat64 st' has incomplete type and cannot be defined
npm ERR!  1229 |         struct STAT64_STRUCT st;
npm ERR!       |                              ^~
npm ERR! ../src/pipeline.cc:1230:55: error: invalid use of incomplete type 'struct PipelineWorker::OnOK()::stat64'
npm ERR!  1230 |         if (STAT64_FUNCTION(baton->fileOut.data(), &st) == 0) {
npm ERR!       |                                                       ^
npm ERR! ../src/pipeline.cc:44:23: note: forward declaration of 'struct PipelineWorker::OnOK()::stat64'
npm ERR!    44 | #define STAT64_STRUCT stat64
npm ERR!       |                       ^~~~~~
npm ERR! ../src/pipeline.cc:1229:16: note: in expansion of macro 'STAT64_STRUCT'
npm ERR!  1229 |         struct STAT64_STRUCT st;
npm ERR!       |                ^~~~~~~~~~~~~
npm ERR! make: *** [sharp-linuxmusl-x64.target.mk:162: Release/obj.target/sharp-linuxmusl-x64/src/pipeline.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Linux 6.5.0-21-generic
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /opt/app/node_modules/ipx/node_modules/sharp
npm ERR! gyp ERR! node -v v20.11.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-02-27T17_01_58_488Z-debug-0.log
lionhu commented 4 months ago

same problem.

lionhu commented 4 months ago

Following works for me, but not node20

strapi-plugin-local-image-sharp@^1.7.0

FROM node:18.13-alpine3.16

Installing libvips-dev for sharp Compatibility

RUN apk update && \ apk upgrade && \ apk add --no-cache build-base make gcc g++ python3 autoconf automake zlib-dev libpng-dev nasm bash vips-dev ARG NODE_ENV=development ENV NODE_ENV=${NODE_ENV}

WORKDIR /opt/ COPY package.json yarn.lock ./ RUN yarn config set network-timeout 600000 -g && yarn install --unsafe-perm

WORKDIR /opt/app COPY . . ENV PATH /opt/node_modules/.bin:$PATH RUN chown -R node:node /opt/app USER node

RUN ["yarn", "build"]

EXPOSE 1337 CMD ["yarn", "dev"]

lionhu commented 4 months ago

anyone success with node.20?

chris-barklem commented 4 months ago

Unless we can raise to node 20.5.0 we are going to miss out on all the changes in: "@strapi/plugin-graphql": "^4.20.5", "@strapi/plugin-i18n": "^4.20.5", "@strapi/plugin-users-permissions": "^4.20.5", "@strapi/provider-upload-aws-s3": "^4.20.5", "@strapi/strapi": "^4.20.5",