Solved: Cannot find module '../build/Release/sharp.node'

If you built Docker image with compiled binaries for Linux, you cannot run this image on Windows.

Dockerized Sharp installed with --arch=x64 --platform=linux will end up with error:

/app/node_modules/sharp/lib/constructor.js:34
  throw new Error(error);
        ^

Error:
Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp.node'
Require stack:
- /app/node_modules/sharp/lib/constructor.js
- /app/node_modules/sharp/lib/index.js

- Run "npm rebuild --verbose sharp" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/install
- Search for this error at https://github.com/lovell/sharp/issues

    at Object.<anonymous> (/app/node_modules/sharp/lib/constructor.js:34:9)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Module.require (internal/modules/cjs/loader.js:1090:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.<anonymous> (/app/node_modules/sharp/lib/index.js:3:15)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)

Solution

Remove --arch=x64 --platform=linux:

RUN npm install --arch=x64 --platform=linux --ignore-scripts=false --verbose

To:

RUN npm install --ignore-scripts=false --verbose