Strapi Docker error sharp

System Information
  • Strapi Version: 4.12.4
  • Operating System: Windows / Window with WSL2
  • Database: Postgres
  • Node Version: 18.17.2
  • NPM Version: 6.14.17
  • Yarn Version: 1.22.19

I’m following the Strapi installation documentation with Docker
When I go to upload the strapi in docker, the error occurs:

yarn run v1.22.19

$ strapi develop

Starting the compilation for TypeScript files in /opt/app

Building your admin UI with development configuration...

Admin UI built successfully

Error: Could not load js config file /opt/app/node_modules/@strapi/plugin-upload/strapi-server.js:

Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp-linuxmusl-x64.node'

Require stack:

- /opt/app/node_modules/sharp/lib/sharp.js

- /opt/app/node_modules/sharp/lib/constructor.js

- /opt/app/node_modules/sharp/lib/index.js

- /opt/app/node_modules/@strapi/plugin-upload/server/services/image-manipulation.js

- /opt/app/node_modules/@strapi/plugin-upload/server/services/index.js

- /opt/app/node_modules/@strapi/plugin-upload/server/index.js

- /opt/app/node_modules/@strapi/plugin-upload/strapi-server.js

- /opt/app/node_modules/@strapi/utils/dist/import-default.js

- /opt/app/node_modules/@strapi/utils/dist/index.js

- /opt/app/node_modules/@strapi/strapi/lib/services/entity-service/components.js

- /opt/app/node_modules/@strapi/data-transfer/dist/strapi/queries/entity.js

- /opt/app/node_modules/@strapi/data-transfer/dist/strapi/queries/index.js

- /opt/app/node_modules/@strapi/data-transfer/dist/strapi/providers/local-destination/strategies/restore/index.js

- /opt/app/node_modules/@strapi/data-transfer/dist/strapi/providers/local-destination/strategies/index.js

- /opt/app/node_modules/@strapi/data-transfer/dist/strapi/providers/local-destination/index.js

- /opt/app/node_modules/@strapi/data-transfer/dist/strapi/providers/index.js

- /opt/app/node_modules/@strapi/data-transfer/dist/strapi/index.js

- /opt/app/node_modules/@strapi/data-transfer/dist/index.js

- /opt/app/node_modules/@strapi/strapi/lib/commands/utils/data-transfer.js

- /opt/app/node_modules/@strapi/strapi/lib/commands/actions/export/command.js

- /opt/app/node_modules/@strapi/strapi/lib/commands/index.js

- /opt/app/node_modules/@strapi/strapi/bin/strapi.js

Possible solutions:

- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"

- Install for the current linuxmusl-x64 runtime: "npm install --platform=linuxmusl --arch=x64 sharp"

- Consult the installation documentation: https://sharp.pixelplumbing.com/install

at loadJsFile (/opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:18:11)

at loadFile (/opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:35:14)

at Object.loadPlugins (/opt/app/node_modules/@strapi/strapi/lib/core/loaders/plugins/index.js:103:26)

at async Strapi.loadPlugins (/opt/app/node_modules/@strapi/strapi/lib/Strapi.js:346:5)

at async Promise.all (index 2)

at async Strapi.register (/opt/app/node_modules/@strapi/strapi/lib/Strapi.js:382:5)

at async Strapi.load (/opt/app/node_modules/@strapi/strapi/lib/Strapi.js:492:5)

at async workerProcess (/opt/app/node_modules/@strapi/strapi/lib/commands/actions/develop/action.js:110:26)

Done in 4.05s.

I followed and installed sharp as shown in the message, but it didn’t solve it.

Possible solutions:

  • Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"

  • Install for the current linuxmusl-x64 runtime: "npm install --platform=linuxmusl --arch=x64 sharp"

I using Window with WSL2

Because you are using yarn for Windows. Try installing yarn in WSL2 as well.