Strapi does not run on Mac M1

I am trying to run Strapi admin panel on my Mac M1. I have setup the Rosetta terminal for the same.
After running yarn develop, I am getting the following error.

Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp-darwin-x64.node'
Require stack:
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/sharp/lib/sharp.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/sharp/lib/constructor.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/sharp/lib/index.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/@strapi/plugin-upload/server/services/image-manipulation.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/@strapi/plugin-upload/server/services/index.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/@strapi/plugin-upload/server/index.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/@strapi/plugin-upload/strapi-server.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/@strapi/strapi/lib/core/app-configuration/config-loader.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/@strapi/strapi/lib/core/app-configuration/index.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/@strapi/strapi/lib/commands/develop.js
- /Users/chanondler/Desktop/repos/tower-mapper-strapi/node_modules/@strapi/strapi/bin/strapi.js

There are multiple solutions on the web, but which one would be the correct. My Nodejs Version in 16.14.0

Install NVM,
use NVM to install nodejs 14
Run strapi with nodejs 14.

Strapi works on my M1 like this

4 Likes

I had this issue, but I needed node 18 for other npm packages I wanted to use.

Here’s how i got it working on (bit of a hack for M1):

  • Like you say, using node 14 works on Mac M1…so I did that first - I used node 14.17.4 and npm installed on a project running strapi 4.4.3

  • then i copied the sharp folder from node_modules which will be used later

  • next, I switch to node 18.6.0 and upgrade strapi to 4.11.4, and install packages with npm install --legacy-peer-deps (without legacy-peer-deps something was failing)

  • at this point, running the project results in the sharp error

  • for the fix, I replace the sharp folder in node_modules with the one I copied back in the earlier step

  • then I ran npm install --platform=darwin --arch=arm64v8 sharp

  • running that must update the sharp in node_modules but it also puts a new sharp folder inside node_modules/@strapi/plugin-upload, which I then delete!

  • then rebuild and run , and it worked so I can continue using node 18 with mac m1

overall, maybe not all the steps are needed, but I’ve done the above process twice and it worked both times with different projects - i think the issue is the extra sharp that is inside node_modules/@strapi/plugin-upload