Yarn develop issue with sharp when executing

I am using the latest version of:

Strapi 4.13.7.
node -v
v18.17.1
❯ npm --version
9.6.7
❯ yarn --version
1.22.19

I am on a Apple M1 Max with 64gb of ram

This is my package.json:
{
“name”: “my-project”,
“private”: true,
“version”: “0.1.0”,
“description”: “A Strapi application”,
“scripts”: {
“develop”: “strapi develop”,
“start”: “strapi start”,
“build”: “strapi build”,
“strapi”: “strapi”
},
“devDependencies”: {},
“dependencies”: {
@strapi/strapi”: “4.13.7”,
@strapi/plugin-users-permissions”: “4.13.7”,
@strapi/plugin-i18n”: “4.13.7”,
“better-sqlite3”: “8.6.0”
},
“author”: {
“name”: “A Strapi developer”
},
“strapi”: {
“uuid”: “cbcbf8a0-ed34-4fd4-8941-63e8687f5231”
},
“engines”: {
“node”: “>=16.0.0 <=20.x.x”,
“npm”: “>=6.0.0”
},
“license”: “MIT”
}

But this is the error I get when I run the project:

❯ yarn develop
yarn run v1.22.19
$ strapi develop
Building your admin UI with development configuration...
Admin UI built successfully
Error: Could not load js config file /Users/mymachine/GitHub/my-project/node_modules/@strapi/plugin-upload/strapi-server.js:
Something went wrong installing the "sharp" module
 
dlopen(/Users/mymachine/GitHub/my-project/node_modules/sharp/build/Release/sharp-darwin-arm64v8.node, 0x0001): Library not loaded: /opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib
  Referenced from: <34EC9DD4-F027-30F1-ABD4-70161DA46595> /opt/homebrew/Cellar/libmatio/1.5.23/lib/libmatio.11.dylib
  Reason: tried: '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file, not in dyld cache)
 
Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
- Install for the current darwin-arm64v8 runtime: "npm install --platform=darwin --arch=arm64v8 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
    at loadJsFile (/Users/mymachine/GitHub/my-project/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:18:11)
    at loadFile (/Users/mymachine/GitHub/my-project/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:35:14)
    at Object.loadPlugins (/Users/mymachine/GitHub/my-project/node_modules/@strapi/strapi/lib/core/loaders/plugins/index.js:103:26)
    at async Strapi.loadPlugins (/Users/mymachine/GitHub/my-project/node_modules/@strapi/strapi/lib/Strapi.js:352:5)
    at async Promise.all (index 3)
    at async Strapi.register (/Users/mymachine/GitHub/my-project/node_modules/@strapi/strapi/lib/Strapi.js:392:5)
    at async Strapi.load (/Users/mymachine/GitHub/my-project/node_modules/@strapi/strapi/lib/Strapi.js:503:5)
    at async workerProcess (/Users/mymachine/GitHub/my-project/node_modules/@strapi/strapi/lib/commands/actions/develop/action.js:110:26)
✨  Done in 3.04s.

Anyone have a clue why this is happening? I am able to run Gatsby projects with sharp. Is this a node issue, do I need to uninstall node, npm and yarn and reinstall them?

Hi, Did you ever manage to solve this? I am getting the same error on my M1 mac. Thanks!

In my particular case, I had installed sharp both via brew, and npm.

Reinstalling npm didn’t help until I uninstalled everything with npm in my brew installations.

A very time consuming exercise… :slight_smile:

Hope this helps

yes I think I have a simular conflict, will give that a try thanks!