Sharp: [Something went wrong installing the 'sharp' module] when running expo optimize

Created on 12 May 2019  路  5Comments  路  Source: lovell/sharp

Iam trying to run expo optimize, but always run into this error:

`Something went wrong installing the "sharp" module
Cannot find module '../build/Release/sharp.node'

At first, I checked if sharp even is installed but it wasn't. So I ran
npm install sharp --save

The module '..build/Release/sharp.node' exists now, but I still get the same error.
I tried uninstalling all my modules and rerun npm install, but still the same error.
My package.json:

{ "main": "node_modules/expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "eject": "expo eject", "test": "node ./node_modules/jest/bin/jest.js --watchAll" }, "jest": { "preset": "jest-expo" }, "dependencies": { "@expo/samples": "2.1.1", "axios": "^0.18.0", "expo": "^32.0.0", "react": "16.5.0", "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz", "react-native-calendars": "^1.60.0", "react-native-elements": "^1.1.0", "react-native-htmlview": "^0.14.0", "react-native-map-link": "^2.4.0", "react-native-vector-icons": "^6.0.0", "react-navigation": "^3.0.9", "react-redux": "6.0.0", "redux": "^4.0.1", "redux-thunk": "^2.3.0", "sharp": "^0.22.1" }, "devDependencies": { "babel-preset-expo": "^5.0.0", "jest-expo": "^32.0.0" }, "private": true }

Is there anything I miss? Do there exist any problems with sharp and some of the packages I use?

Most helpful comment

npm uninstall expo-cli -g

and then

npm install expo-cli -g

solved this issue for me

All 5 comments

Removing expo client and Node.js completely to then reinstall the latest versions solved my issue.

npm uninstall expo-cli -g

and then

npm install expo-cli -g

solved this issue for me

just to save everyone a second or two of doubt:

npm uninstall expo-cli -g (an n was missing)

I got similar error with cordova-res:

The module '/usr/local/lib/node_modules/cordova-res/node_modules/sharp/build/Release/sharp.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 67. This version of Node.js requires ...

As you said, uninstall and install as globally worked:

npm uninstall -g cordova-res

npm i -g cordova-res

Thanks.

For Windows user commands are as followings:

npm uninstall --g expo-cli
npm install --g expo-cli

Was this page helpful?
0 / 5 - 0 ratings