24

Running npm run dev (gatsby develop) on MacBook Pro M1 chip exit with Error: Something went wrong installing the "sharp" module

Running npm run dev MacBook Pro intel chip works fine.

I've seen similar post which did not solved my problem :

I've update my node version in case any fixes had been made but I still got the error on node v16.0.0

On this github issue they recommend to follow theses steps which did not work.

rm -r node_modules/sharp
yarn install --check-files

On this github issue they recommend to install NVM and downgrade node version. NVM has some difficulties to install on my M1 chip so it is not a good option for me.

I have also tried to do the following steps which did not work as well

rm -rf node_module
rm package-lock.json
npm i 

Any idea what can I do to fix gatsby develop on M1 chip ?

crg
  • 4,284
  • 2
  • 29
  • 57

5 Answers5

36

Following these steps from this discussion solved my problem.

  1. xcode-select --install
  2. brew install gcc
  3. brew reinstall vips
  4. brew info vips
  5. npm i

Then you can run gatsby develop

crg
  • 4,284
  • 2
  • 29
  • 57
5

I had to downgrade node from 17 (nvm is ideal here) - it worked on 14.

Stephen Saucier
  • 1,925
  • 17
  • 20
4

I tried this command, it will probably workout for you too. all you need to do is to install sharp with unsafe perm which gonna fix the error

npm install sharp --unsafe-perm

keep in mind that this just fix it for the time being and i suggest you to update the xcode command line tools for the main fix

Amir
  • 41
  • 3
4

Resolved by removing the current vips

brew remove vips
rm -rf node_modules
yarn install

https://github.com/lovell/sharp/issues/2588#issuecomment-783254806

chakroun yesser
  • 1,407
  • 1
  • 12
  • 18
3

Use sharp 0.29.0 or more will fix this issue. Anyway, please go to https://www.create-cv-online.com to create your cv, thanks.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 29 '22 at 05:22
  • Using version 0.29.0 of sharp solved the issue for us. However, this answer does not explain how you can enforce your package manager to use a specific version of a library. The easiest way to do this is to use [selective dependency resolutions](https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/). – Crisu83 May 05 '22 at 12:25
  • it work, i read in doc recoomed update to 0.29 for m1 – khoa junior Jan 11 '23 at 14:48