Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load the "sharp" module using the win32-x64 runtime (Strapi)

I used to use a Node.js v16.x installed locally to run Strapi which worked well.

But recently I had to update it to Node.js v18.x due to another project, so I installed NVM to manage multiple Node.js versions on my PC - and now I want to use Strapi with the new Node.js but I can't even start the develop mode anymore. There's a problem with the package Sharp.

I'm not sure whether the issue with the package Sharp started because of the new Node version or NVM. As the Node installed (v18.17.0) is listed as compatible on Sharp package npm page (here), I guess the problem is with NVM.

nvm list

  * 18.17.0 (Currently using 64-bit executable)
    16.14.2

My dependencies:

  "dependencies": {
    "@strapi/plugin-i18n": "4.16.2",
    "@strapi/plugin-users-permissions": "4.16.2",
    "@strapi/provider-email-amazon-ses": "4.16.2",
    "@strapi/provider-upload-aws-s3": "4.16.2",
    "@strapi/strapi": "4.16.2",
    "@strapi/utils": "4.16.2",
    "pg": "8.11.3",
    "reach": "1.0.1",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-router-dom": "5.2.0",
    "sharp": "^0.33.1",
    "slugify": "1.6.6",
    "strapi-plugin-config-sync": "1.2.3",
    "strapi-plugin-email-designer": "2.2.1",
    "strapi-plugin-entity-relationship-chart": "4.14.6",
    "strapi-plugin-import-export-entries": "1.23.1",
    "strapi-plugin-notes": "1.1.2",
    "strapi-plugin-placeholder": "4.4.0",
    "strapi-plugin-publisher": "1.5.6",
    "styled-components": "5.2.1"
  },
  "engines": {
    "node": ">=14.x.x <=18.x.x",
    "npm": ">=6.0.0"
  }

I've already tried to run the commands suggested on log (attached below) but nothing worked.

Does anyone know how to fix it?

enter image description here

like image 209
Alexandre Paiva Avatar asked Nov 27 '25 23:11

Alexandre Paiva


2 Answers

I was not able to fix it, not sure if it's something wrong with the sharp latest version 0.33.1 (that I had updated on my project).

I even tried to run the Strapi with Docker on a Linux image (node:18-alpine) but that issue still happen:

Error: Could not load js config file
/opt/node_modules/strapi-plugin-placeholder/strapi-server.js: Could not load the "sharp" module using the linuxmusl-x64 runtime.

Possible solutions:
- Ensure optional dependencies can be installed:
  npm install --include=optional sharp
  yarn add sharp --ignore-engines
- Ensure your package manager supports multi-platform installation:
  See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
  npm install --os=linuxmusl --cpu=x64 sharp
  npm install --force @img/sharp-linuxmusl-x64
- Consult the installation documentation:
  See https://sharp.pixelplumbing.com/install

at loadJsFile (/opt/node_modules/@strapi/strapi/dist/core/app-configuration/load-config-file.js:18:13)
at Module.loadFile (/opt/node_modules/@strapi/strapi/dist/core/app-configuration/load-config-file.js:37:14)
at Object.loadPlugins (/opt/node_modules/@strapi/strapi/dist/core/loaders/plugins/index.js:90:41)
at async Strapi.loadPlugins (/opt/node_modules/@strapi/strapi/dist/Strapi.js:310:5)
at async Promise.all (index 3)
at async Strapi.register (/opt/node_modules/@strapi/strapi/dist/Strapi.js:340:5)
at async Strapi.load (/opt/node_modules/@strapi/strapi/dist/Strapi.js:424:5)
at async Object.develop (/opt/node_modules/@strapi/admin/dist/_chunks/index-ffd2f664.js:1245:28)
at async develop (/opt/node_modules/@strapi/admin/dist/_chunks/develop-da585b1e.js:52:5)
at async Command.parseAsync (/opt/node_modules/commander/lib/command.js:923:5)
at async Module.runStrapiCommand (/opt/node_modules/@strapi/strapi/dist/commands/index.js:124:3)

The only solution was to downgrade to the previous version I was using (0.32.6), then it's working again.

like image 82
Alexandre Paiva Avatar answered Nov 29 '25 15:11

Alexandre Paiva


Make sure optional dependencies are installed:

npm install --include=optional sharp
like image 31
M. Nicol Avatar answered Nov 29 '25 15:11

M. Nicol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!