Failed to find the instance of sharp used by the global sharp-cli package
Asked Answered
C

1

6

When attempting to run Expo for web I get the error "Failed to find the instance of sharp used by the global sharp-cli package" after creating a file namedwebpack.config.js in the root of my app folder. The contents of the file can be as simple as the default expo implementation and still fail:

module.exports = async function(env, argv) {
    const loadDefaultConfigAsync = require('@expo/webpack-config');
    return await loadDefaultConfigAsync(env, argv);
};

Node Version: v16.3.1

NPM Version: v8.1.2

{
  "name": "foo",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "test": "jest --watchAll"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.0",
    "@expo/webpack-config": "^0.16.11",
    "@react-navigation/bottom-tabs": "^6.0.5",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/native-stack": "^6.1.0",
    "expo": "~43.0.2",
    "expo-asset": "~8.4.3",
    "expo-constants": "~12.1.3",
    "expo-font": "~10.0.3",
    "expo-linking": "~2.4.2",
    "expo-splash-screen": "~0.13.5",
    "expo-status-bar": "~1.1.0",
    "expo-web-browser": "~10.0.3",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.8.0",
    "react-native-web": "0.17.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@types/react": "~17.0.21",
    "@types/react-native": "~0.64.12",
    "jest-expo": "~43.0.0",
    "typescript": "~4.3.5"
  },
  "private": true
}
Capel answered 5/12, 2021 at 18:22 Comment(0)
C
17

After some searching online I came up empty handed for a simple solution that worked. I managed to work around this issue by installing sharp-cli as a local dependency and saving it to the package.json using the following command:

npm install --save-dev sharp-cli
Capel answered 5/12, 2021 at 18:22 Comment(1)
Should be added as a development dependency (--save-dev) to not include it in the app bundle: npm install --save-dev sharp-cliVadose

© 2022 - 2024 — McMap. All rights reserved.