react-native-svg: Can not resolve module

Hey guys, I recently ejected my app and updated to ExpoKit 35, and since then, I can’t launch the app on iOS anymore because there’s a problem with the react-native-svg module.

Commands :

  • expo install react-native-svg
  • cd ios && pod install
  • cd .. && expo start -c
  • Build and run on Xcode

Error below :

While trying to resolve module react-native-svg from file /project/assets/illustrations/demo.svg, the package /project/node_modules/react-native-svg/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/project/node_modules/react-native-svg/src/index.ts. Indeed, none of these files exist:

/project/node_modules/react-native-svg/src/index.ts(.native||.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.svg|.native.svg|.svg|.ios.json|.native.json|.json)

/project/node_modules/react-native-svg/src/index.ts/index(.native||.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.svg|.native.svg|.svg|.ios.json|.native.json|.json)

Any of you guys had this issue before ? Any help appreciated 😃

I am currently using the following versions :

Expo : 35.0.0 ExpoKit : 35.0.1 React-native : https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz ( SDK 35 ) React-native-svg : 9.12.0 ( When installing, yarn says that version ~9.9.2 is required, but it gaves me the same error anyways ) CocoaPods : 1.8.3 Xcode : 11.1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 27

Most upvoted comments

I had the same issue, with same steps and same outcome. Figured out that in my app.json i had "packagerOpts": { "config": "metro.config.js", "sourceExts": ["js","jsx","svg",] }, insead of "packagerOpts": { "config": "metro.config.js", "sourceExts": [ "js","jsx","svg","ts","tsx"] }, changing that fixed my issue

I could not manage to resolve issue by @RobertMeGusta comments. Still having the same problem 😦 Do you have any other suggestions

npm i react-native-svg solved for me

@feliperoan Can you try v9.13.2? Or yarn add css-tree css-select #1166 (comment)

perfect, thank you

I think problem is with react-native-svg >= 12.0.0. Yarn add react-native-svg@11.0.0 solved all issues

npm i react-native-svg work for me to

To reconfirm this can be resolved, when using metro.config.js by adding “ts” and “tsx” to the sourceExts as follows:

module.exports = {
  resolver: {
    sourceExts: ["js", "ts", "jsx", "tsx", "json"],
  },
  ...

I did already : expo init test yarn add react-native-svg@9.13.2 expo eject => ExpoKit cd ios && pod install expo start -c Build and Run on Xcode

And everything works fine 😕

Hi I have the same error for a few hours I already deleted modules reinstall from scratch and I don’t have the solution Loading dependency graph, done. error: bundling failed: Error: Unable to resolve module css-selectfromD:\Developement\dos\CloudMobile\SiigoApp\node_modules\react-native-svg\src\css.tsx: Module css-select` does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968 To resolve try the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache.
  4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*.`

this from today, do you know how I can fix it?