I'm installing the Sharp
package for image compression on the docker image for a Nodejs project with package.json.
When I create the container I get the following error regarding to the sharp package:
/app/node_modules/sharp/lib/libvips.js:67
throw new Error(`'${vendorPlatformId}' binaries cannot be used on the '${currentPlatformId}' platform. Please remove the 'node_modules/sharp/vendor' directory and run 'npm install'.`);
^ Error: 'linux-x64' binaries cannot be used on the 'linuxmusl-x64' platform. Please remove the 'node_modules/sharp/vendor' directory and run 'npm install'.
at Object.hasVendoredLibvips (/app/node_modules/sharp/lib/libvips.js:67:13)
at Object.<anonymous> (/app/node_modules/sharp/lib/constructor.js:8:22)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/app/node_modules/sharp/lib/index.js:3:15)'.
I have removed the whole node_module directory and reran the npm install
command in the directory to reinstall all pack and also rebuilt the docker image but I'm still getting the error.
Any recommendations on how to fix this issue is appreciated.
RUN npm install
in your Dockerfile, make sure thenode_modules
directory is listed in a.dockerignore
file, and you should not have anydocker run -v
options hiding or otherwise overwriting the code in the image.) – Schlueterdocker-compose
to build image and run it, also in the Dockerfile, I usedRun npm install
command; I removed the image and rebuilt it, the sharp package installed successfully without any error but when I run the container I get the above error! I haven't.dockerignore
file! Is it cause this error? – Susansusana