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

Ambiguous resolution of react-native #15789

Closed
CaptainOfFlyingDutchman opened this issue Sep 4, 2017 · 27 comments
Closed

Ambiguous resolution of react-native #15789

CaptainOfFlyingDutchman opened this issue Sep 4, 2017 · 27 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@CaptainOfFlyingDutchman
Copy link

CaptainOfFlyingDutchman commented Sep 4, 2017

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

  1. react-native -v: 2.0.1
  2. node -v: v8.4.0
  3. npm -v: 5.3.0
  4. yarn --version:

Then, specify:

  • Target Platform: Android
  • Development Operating System: Windows 10 Home
  • Build tools: Android Studio

Steps to Reproduce

(Write your steps here:)

  1. Rename node_modules directory to node_modules_.
  2. Delete android directory.
  3. Execute npm i
  4. Execute react-native upgrade
  5. Execute react-native run-android

After not working I even deleted the node_modules_ directory. But the problem still persists.

Expected Behavior

It should just work as expected, run the app in the Android emulator.

Actual Behavior

It's not working. React packager is complaining.

Reproducible Demo

https://github.com/ManvendraSK/ChatNowReactNativeSampleApp

packager
command
emulator

@CaptainOfFlyingDutchman
Copy link
Author

I have recreated the emulator after deleting it. I tried a new app and existing apps, they all are working fine.

@radko93
Copy link
Contributor

radko93 commented Sep 4, 2017

What's the point of having two node_modules folders?

@CaptainOfFlyingDutchman
Copy link
Author

Obviously nothing. See I renamed it to node_modules_ (with extra underscore). But later I deleted it after the problem arose. But still, it is complaining to resolve from this underscored directory too! How can it be?

Moreover, we can't have two folders with the same name on Windows.

@radko93
Copy link
Contributor

radko93 commented Sep 5, 2017

Have you tried cleaning cache? Still, I can't see any point in doing this.

@jonathanoron
Copy link

I'm having the same problem.
It's pointing to package.json files in directories that no longer exists.
Have tried npm cache clean yarn cache clean etc...
Keeps trying to resolve the react_native module to the non-existent dirs.

@CaptainOfFlyingDutchman
Copy link
Author

Yes, I had tried deleting android, ios, build and node_modules directories. Then npm i followed by react-native upgrade that generates ios and android directories. Then react-native run-android and this problem occurs again.

I know no point in doing this, but all I wanted to reinstall node_modules but I didn't want the time consumed in deleting existing node_modules folder, so I just renamed it to node_modules_ folder.

Now could you please help?

@radko93
Copy link
Contributor

radko93 commented Sep 5, 2017

Maybe clean watchman cache then? If not, unfortunately, I have no clue about this.

@CaptainOfFlyingDutchman
Copy link
Author

Ohk, I'll try cleaning watchman cache. How to do it? Command? Directory? I'll keep you posted here. Thanks.

@jonathanoron
Copy link

@ManvendraSK try watchman watch-del-all
Unfortunately, it did not help me 😞

@CaptainOfFlyingDutchman
Copy link
Author

@jonathanoron I'll try when back at home, right now in office ;-).

Let's see what is next, I'll keep you posted here. May be somebody would help like Batman! :-P

@jonathanoron
Copy link

@ManvendraSK npm start -- --reset-cache saved the day for me:
#1924 (comment)

@CaptainOfFlyingDutchman
Copy link
Author

Thanks @jonathanoron. I'll try it when at home. 👍

@CaptainOfFlyingDutchman
Copy link
Author

Hey @jonathanoron and @radko93, it's working fine!

npm start -- --reset-cache does work! But, after it has executed we need to kill this command and start with the usual one react-native run-android. watchman didn't work though!

Thanks, guys. You both are Batman for me!

@radko93
Copy link
Contributor

radko93 commented Sep 5, 2017

@facebook-github-bot answered

@facebook-github-bot
Copy link
Contributor

Closing this issue as @radko93 says the question asked has been answered.

@facebook-github-bot facebook-github-bot added the Ran Commands One of our bots successfully processed a command. label Sep 5, 2017
@DanielRamosAcosta
Copy link

In my case, It seems that I had conflicts between .yarn directory and node_modules, despite I did a clean yarn install.

Deleting .yarn and starting the app with npm start solved this problem for me, but it doesn't feel like the correct solution.

@pkshefi
Copy link

pkshefi commented Sep 16, 2017

i tried to install,
npm install --save react-native-router-flux@3.38.0
npm install -g react-native-git-upgrade
react-native-git-upgrade

fixed thanks folks

@yummyelin
Copy link

Reboot mac works

@DanielRamosAcosta
Copy link

Also, delete system32

@noumantahir
Copy link

noumantahir commented Jan 8, 2018

having this same issue, I am on mac, restarting doesn't work, neither refreshing node_modules and clearing cache..

using :
"react": "16.0.0",
"react-native": "0.50.1",

Is there anything else I can try

simulator screen shot - iphone 6 - 2018-01-09 at 03 34 47

@jooleeanh
Copy link

jooleeanh commented Jan 9, 2018

For those of you trying to create a library/bridge:

I just got this error, and it was because I had put an example app inside my library:

.
├── README.md
├── android
│   ├── build.gradle
│   └── src
├── example
│   ├── App.js
│   ├── __tests__
│   ├── android
│   ├── app.json
│   ├── index.js
│   ├── ios
│   ├── node_modules
│   ├── package.json
│   └── yarn.lock
├── index.js
├── ios
│   └── app.xcodeproj
├── node_modules
├── package.json
└── yarn.lock

Which means that when I ran react-native run-android, my index.js would find react-native in ./example/node_modules, but also in ./example/node_modules/MyApp/example/node_modules/....

The fix was to add a ./.npmignore file with example/* which prevents this recursion from happening, and make sure that ./package.json didn't have react-native in its dependencies (peerDependencies is okay).

I then did:

  • cancel any yarn/npm/react-native processes (those that are started from run-android)
  • delete node_modules in both ./ and ./example/
  • yarn in both ./ and ./example/
  • yarn start --reset-cache from ./example/

Edit: Finally noticed that my issue is related to a yarn issue. They don't seem to have a fix besides downgrading to 0.26.1 (which introduced another bug for me), so will have to do with the above for now.

@derdrdirk
Copy link

For me the error appeared in calling my Project ReactNative!
As soon as I changed the name to something different than ./ReactNative the error disappeared!

@reinvanimschoot
Copy link

Any idea when this will be solved? For now I cannot install any pods that install React as well.

@akvsh-r
Copy link

akvsh-r commented Mar 18, 2018

If nothing helps remove duplicate dependencies from Pods & react native links. Then clear Pods cache & reinstall them using this : gist
then do above stuff. Spent half day on this

@evanjmg
Copy link

evanjmg commented Jun 2, 2018

Generally this issue arises when there are two folders of react-native. More often, if you use Pods, you have dependency that relies on the 'React' pod and thus you should reference the pod in your node_modules/ not install anothe react-native from cocopods. To do so, you can add the following to your Podfile

  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'React', :path => '../node_modules/react-native'

@cameck
Copy link

cameck commented Jul 15, 2018

Full reset that worked for me:

#!/bin/bash
echo "Completely resetting life"
echo "STARTING: Deleting Node modules"
rm -rf ./node_modules
echo "FINISHED: Deleting Node modules"
echo "STARTING: Removing yarn.lock file"
rm yarn.lock
echo "FINISHED: Removing yarn.lock file"
echo "STARTING: Deleting Watchman and yarn cache"
watchman watch-del-all
yarn cache clean
echo "STARTING: Re-installing node modules"
yarn install
echo "FINISHED: Re-installing node modules"
echo "STARTING: restarting app"
yarn start --reset-cache

@imapolaris
Copy link

npm start -- --reset-cache solved the problem for me. thx!!!

@facebook facebook locked as resolved and limited conversation to collaborators Sep 5, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Sep 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests