Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not resolve module #1165

Closed
Clonescody opened this issue Oct 23, 2019 · 29 comments
Closed

Can not resolve module #1165

Clonescody opened this issue Oct 23, 2019 · 29 comments
Labels
Missing repro This issue need minimum repro scenario

Comments

@Clonescody
Copy link

Clonescody commented Oct 23, 2019

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

@msand
Copy link
Collaborator

msand commented Oct 23, 2019

Hmm, well that file certainly exists in the repo and on npm, can you check that it exists in your node_modules?

@msand msand added the Missing repro This issue need minimum repro scenario label Oct 23, 2019
@feliperoan
Copy link

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 facebook/react-native#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?

@msand
Copy link
Collaborator

msand commented Oct 23, 2019

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

@feliperoan
Copy link

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

perfect, thank you

@Clonescody
Copy link
Author

@msand The package.json exists inside the react-native-svg module, however, as specified in the error, the /node_modules/react-native-svg/src/index.ts file is missing , index.js is present thought

@msand
Copy link
Collaborator

msand commented Oct 24, 2019

@Clonescody seems you have some strange combination of old code and new code, index.js hasn't existed for quite some time. https://unpkg.com/browse/[email protected]/src/

@Clonescody
Copy link
Author

Clonescody commented Oct 24, 2019

@msand, I updated to 9.13.2, still getting the same error, even thought the .ts file is present this time :

ls -l ./node_modules/react-native-svg/src/

-rw-r--r-- ReactNativeSVG.ts
-rw-r--r-- ReactNativeSVG.web.ts
-rw-r--r-- css.tsx
drwxr-xr-x elements
-rw-r--r-- index.d.ts
-rw-r--r-- index.js.flow
-rw-r--r-- index.ts
drwxr-xr-x lib
-rw-r--r-- xml.tsx

I tried to remove/reinstall node_modules completely but still nothing :(

EDIT : I tried to reproduce on a brand new expo project ejected with ExpoKit and everyhting works as intended ...

@msand
Copy link
Collaborator

msand commented Oct 24, 2019

Can you try this?

watchman watch-del-all
rm -fr $TMPDIR/react-*
react-native start --reset-cache

@Clonescody
Copy link
Author

I tried the commands, when i'm starting the packager with react-native start --reset-cache and launching the app with react-native run-ios, the app is loading but ends up crashing after a black screen.

When using expo start -c instead of the react-native start command, I keep getting the module error

@msand
Copy link
Collaborator

msand commented Oct 24, 2019

Can you try making a clean project and try it there?

@Clonescody
Copy link
Author

I did already :
expo init test
yarn add [email protected]
expo eject => ExpoKit
cd ios && pod install
expo start -c
Build and Run on Xcode

And everything works fine :/

@RobertMeGusta
Copy link

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

@Clonescody
Copy link
Author

Clonescody commented Oct 28, 2019

I tried everything that was suggested but it still didn't work.

I fixed the issue by going back to my pre-detached app state and redoing the whole installation.

Thanks anyways for the help.

@walidvb
Copy link

walidvb commented Nov 1, 2019

Had the same issue, adding ts and tsx to the list of sourceExts as per #1165 (comment) fixed it

@ExcellentSP
Copy link

@walidvb, Can confirm. #1165 (comment) fixed my issue as well.

@ensargunesdogdu
Copy link

ensargunesdogdu commented Nov 13, 2019

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

@asleepace
Copy link

This thread on SO helped me out:

Delete Pods and Podfile.lock then run pod install

@07734
Copy link

07734 commented Jan 28, 2020

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"],
  },
  ...

@rickli1989
Copy link

#1165 (comment) fixed my issue as well.

@huzaima
Copy link

huzaima commented Apr 20, 2020

I'm still facing this issue with react-native-svg latest version.

ERROR: error: bundling failed: Error: Unable to resolve module css-tree from node_modules/react-native-svg/src/css.tsx: css-tree could not be found within the project or in these directories:
../../node_modules

OS: macOS 10.15.4
CPU: (4) x64 Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz
Memory: 129.73 MB / 8.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.17.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5

@whatdtech
Copy link

@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 [email protected] solved all issues

@youssame
Copy link

youssame commented Oct 8, 2020

@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 [email protected] solved all issues

you're an angel

@neilakoh
Copy link

@asleepace this worked . . removing the Podfile.lock is necessary to get the updates from lastest css-tree modules you installed. In my case the error was "Unable to resolve module ./HexColor" it turns out they rename it from HexColor to Hash so in order to get the updates "Podfile.lock" file has to be removed before running pod install.

@atulugale11
Copy link

npm i react-native-svg solved for me

@rajan-keypress
Copy link

rajan-keypress commented Jan 18, 2021

npm i react-native-svg work for me to

@ummartoor
Copy link

npm i react-native-svg

what about yarn that didn't work ? i'm trying with that

@aqibhassanzeb
Copy link

yarn add react-native-svg @ummartoor

@AsadAsh006
Copy link

I am facing that issue I already imported the css according to error but still facing same error " Error: [react-native-svg] You are trying to import a component WithLocalSvg that has been moved to a sub-package. Change your import from react-native-svg to react-native-svg/css."

@emeraldknight-sp
Copy link

yarn add react-native-svg solved here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario
Projects
None yet
Development

No branches or pull requests