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

react-devtools 3.5.0 breaks new project #22863

Closed
sunnylqm opened this issue Jan 4, 2019 · 61 comments
Closed

react-devtools 3.5.0 breaks new project #22863

sunnylqm opened this issue Jan 4, 2019 · 61 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@sunnylqm
Copy link
Contributor

sunnylqm commented Jan 4, 2019

devtool

reactDevTools.connectToDevTools is not a function

## Environment
  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
      Memory: 833.36 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.15.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 22, 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 23.0.2, 23.0.3, 24.0.1, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.2
        System Images: android-25 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64
    IDEs:
      Android Studio: 3.1 AI-173.4907809
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3
      react-native: 0.57.8 => 0.57.8
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-create-library: 3.1.2
      react-native-debugger-open: 0.3.17
      react-native-git-upgrade: 0.2.7
      react-native-update-cli: 0.1.0

Description

Reproducible Demo

Just init a new project and you'll hit this issue

Workaround

Put the following in your package.json and run yarn (not npm, which does not support "resolutions") to force install the previous version:

  "resolutions": {
    "react-devtools-core": "3.4.3"
  }

Then close the current packager window, run yarn start --reset-cache.

Since the compiled js file changed a lot and we actually got an empty object in setupDevtools.js, so I suspect that something went wrong with build configuration, maybe related to facebook/react-devtools@28d36a2

cc @bvaughn @kelset @hramos

@Flatheadman
Copy link

same problem.

1 similar comment
@ESXHandsome
Copy link

same problem.

@swushi
Copy link

swushi commented Jan 4, 2019

Same issue on two different computers. Workaround without yarn on Windows?

@silencer07
Copy link

silencer07 commented Jan 4, 2019

resolution did not work for me strangely enough, what i did is install this particular version as dev-dependency for the mean time

@trops
Copy link

trops commented Jan 4, 2019

still not working with the workarounds

@jamonholmgren
Copy link
Collaborator

Thanks for reporting! (Please don't comment with "same here" comments; just thumbs-up the issue and subscribe to updates if you want.)

@osamaqarem
Copy link

osamaqarem commented Jan 4, 2019

Same issue.
I decided to learn React Native today, and I struggled for ~3 hours thinking I did something wrong during the "Get Started" guide. I was about to open a new issue to get help... only to find this opened 2 hours ago. Quite the headache 😫

@ppv94
Copy link

ppv94 commented Jan 4, 2019

i am also getting the same error what should i do resolve this error
i have tried this but i am getting same error
"resolutions": {
"react-devtools-core": "3.4.3"
}
what should i do to resolve this issue
screenshot 2019-01-04 at 9 55 56 am

@prav02
Copy link

prav02 commented Jan 4, 2019

I am facing same problems, but when I am trying to run the previous projects that I have created, they all run fine.

@MingFaiYau
Copy link

MingFaiYau commented Jan 4, 2019

After i upgrade react native 0.54.x -> 0.57.8, i got this problem too.

In setupDevtools.js

const reactDevTools = require('react-devtools-core');
reactDevTools return is an Object, not a function , so get error...
So it may be the react-devtools-core/build/backend.js problem..

For my temp solution..
add checking before use reactDevTools or just remove this code..

    if (typeof reactDevTools === 'function') {
      reactDevTools.connectToDevTools({
        isAppActive,
        host,
        // Read the optional global variable for backward compatibility.
        // It was added in https://github.com/facebook/react-native/commit/bf2b435322e89d0aeee8792b1c6e04656c2719a0.
        port: window.__REACT_DEVTOOLS_PORT__,
        resolveRNStyle: require('flattenStyle'),
      });
    }

@jamonholmgren
Copy link
Collaborator

jamonholmgren commented Jan 4, 2019

I would recommend rolling back to [email protected]. I was able to do this and it worked.

yarn add --dev [email protected]
or
npm install --save-dev [email protected]

I will note that this happened on a brand-new 0.57.7 project also.

@ghost
Copy link

ghost commented Jan 4, 2019

God bless you

@chuckntaylor
Copy link

Same issues here. Reverting to [email protected] as @jamonholmgren recommended got me back up and running. Thanks!

@minhphung210
Copy link

the solution not work for me. I use version 0.57.8

@ppv94
Copy link

ppv94 commented Jan 4, 2019

done npm install --save-dev [email protected],
in android its working but in ios simulator its showing the same error.
screenshot 2019-01-04 at 12 55 10 pm
how to resolve this error

@svjkumar
Copy link

svjkumar commented Jan 4, 2019

In android I just disabled JS Dev Mode in Dev settings then error disappears. This is temporary solution only.

@akira-murata
Copy link

@jamonholmgren

yarn add --dev [email protected]

It worked on both android iOS
Thank you

@SilajitBukaiSil
Copy link

@svjkumar how to disabled JS Dev Mode in Dev settings? can you please help me. I am new in react native.

@jordenchang55
Copy link

jordenchang55 commented Jan 4, 2019

Shake your device and then you'll see the develop menu, the last one is Dev settings. BTW, I tried in [email protected], but not work

@SilajitBukaiSil
Copy link

@jamonholmgren the solution is not worked for me

@jordenchang55
Copy link

@minhphung210 Thanks. After 3 hours of struggle, finally I can see welcome text on the screen.

@timesina
Copy link

timesina commented Jan 4, 2019

This solution does not work for 0.57.8 versions
image

@ppv94
Copy link

ppv94 commented Jan 4, 2019

@ppv94. @MingFaiYau solution is worked , you can try its

its working in android but its not working in ios for me.

@jordenchang55
Copy link

jordenchang55 commented Jan 4, 2019

@timesina You need to install the dependency in the devDependecies, i.e., use npm install with --save-dev argument.

@SilajitBukaiSil
Copy link

Shake your device and then you'll see the develop menu, the last one is Dev settings. BTW, I tried in [email protected], but not work

Thanks @jordenchang55 . Its working for me in [email protected]. Just run your project once again.

@seuzxh
Copy link

seuzxh commented Jan 4, 2019

Same issue.

But I use react-devtools-core@3.4.2 not 3.4.3 to make it work.
My react-native version is 0.57.7
Here is my package.json file"

{
  "name": "MyApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.1",
    "react-native": "0.57.7"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.50.0",
    "react-devtools-core": "^3.4.2",
    "react-test-renderer": "16.6.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

@arkhan13
Copy link

arkhan13 commented Jan 4, 2019

not working the heck
npm install --save-dev [email protected] isn't working

@NguyenPhatBG
Copy link

@priyesh321 => @nvmanh and @zhima
You need to delete node_module folder, after that yarn or npm install
Check package.json file, if you not seen react-devtools-core: '3.4.2'
do this: npm install --save-dev [email protected]

@ppv94
Copy link

ppv94 commented Jan 4, 2019

done npm install --save-dev [email protected],
in android its working but in ios simulator its showing the same error.
screenshot 2019-01-04 at 12 55 10 pm
how to resolve this error

I am using 0.57.8, and I encounter the same issue.
I also fix the issue with @jamonholmgren 's command npm install --save-dev [email protected]

At first, it works in android, while iOS still show the error.
Then I run these two command to clean the cache, and react-native run-ios again, and it works.
npm cache clean --force
react-native start --reset-cache

thanks it works for me in android and ios also.

@arkhan13
Copy link

arkhan13 commented Jan 4, 2019

there is one solution to this Within your app in the Android Emulator press Command + M on OSX or Ctrl + M on Linux and Windows.

then go to dev settings

uncheck JD DEV MODE

The first option worked for me

@priyesh321
Copy link

@priyesh321 => @nvmanh and @zhima
You need to delete node_module folder, after that yarn or npm install
Check package.json file, if you not seen react-devtools-core: '3.4.2'
do this: npm install --save-dev [email protected]

thanks its works for me

@SamuelVEshapogu
Copy link

SamuelVEshapogu commented Jan 4, 2019

@sunnylqm thanks
I'm using 0.56, below workaround solved the issue.
"resolutions": {
"react-devtools-core": "3.4.3"
}

@AygnYldz
Copy link

AygnYldz commented Jan 4, 2019

npm install --save-dev [email protected]

it works.

@kulbhushan-ucreate
Copy link

For yarn developer 👍
I'm using 0.57.8, below workaround solved the issue.

"resolutions": {
"react-devtools-core": "3.4.3"
},
add this piece of code and after that delete yarn.lock file and run command:
rm -rf node_modules && yarn install
and its working.

Thanks.

@arkhan13
Copy link

arkhan13 commented Jan 4, 2019

to get rid of this in the first place I decided to create a downgraded react-native version which is 0.55
to do so
run this
react-native init newproject --version [email protected]
0.55 is the version I chose

@SMJ93
Copy link

SMJ93 commented Jan 4, 2019

We are still getting the issue after downgrading react-devtools-core to 3.4.3 and 3.4.2

Our environment:

  • react-native: 0.57.2
  • node: 10.5.0
  • npm: 6.4.1
  • iOS 12.1

Also tried setting react-devtools to 3.4.3 too.

We can't downgrade our react-native version to 0.55 as @arkhan13 as suggested above.

@joerneu
Copy link

joerneu commented Jan 4, 2019

Even after downgrading in "devDependencies" I could still find newer versions of "react-devtools-core" in other modules.

I solved it with yarn by downgrading and changing the version of "react-devtools-core" in all dependent modules:

  "devDependencies": {
    ...
    "react-devtools-core": "3.4.3",
    ...
  },
  "resolutions": {
    "**/react-devtools-core": "3.4.3"
  },

Important: The glob-pattern in "resolutions"!

After deleting the "node_modules" folder and the "yarn.lock" file and running yarn install, the Android app is running without issues.

(with react-native 0.57.8)

@Kouznetsov
Copy link

Does anyone have an idea of what exactly is going wrong here ?
Why is this error appearing now ? Did something change with the RN repo ? I didn't upgrade anything but the issue appeared anyway. As the npm package cannot (they cannot, right ?) change without a version incrementation, I wonder how I came to have this error.

  • If anyone would know the exact reason of the issue (a RN contributor perhaps), it would certainly help.

@sunnylqm
Copy link
Contributor Author

sunnylqm commented Jan 4, 2019

@Kouznetsov The reason I already described in title, that is, caused by the new version of react-devtools-core. A project will contain thousands of third-party libraries, which is why we often saw things break like a curse though we do nothing wrong.

And 1) the npm package can update silently every time you install unless it is locked to a specified version. 2) Even you lock your dependencies, do not forget your dependencies can also have their dependencies which may not have locked versions. And that is exactly what is going wrong right here right now. (react-devtools-core is a dependency of react-native but was updated with a break build since its version not locked)

@sameer-kumar-jain
Copy link

Tried all solutions from this thread but I am still having issue with ios. Attached is my package.json.

{
  "name": "MyAwesomeProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.3",
    "react-native": "0.57.8",
    "react-native-gesture-handler": "^1.0.12",
    "react-navigation": "^3.0.9"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "eslint-config-rallycoding": "^3.2.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-devtools-core": "3.4.2",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  },
  "resolutions": {
    "**/react-devtools-core": "3.4.2"
  }
}

Any idea?

@jasonroyle
Copy link

This fixed it for me running [email protected].

@Richi2293
Copy link

For me it worked only using yarn, otherwise with npm the error remained me.
(added in devDependencies the react-devtools-core and added the resolutions )

@bvaughn
Copy link
Contributor

bvaughn commented Jan 4, 2019

Hi all 👋 Sorry for the trouble 😦

I believe this was something I broke when upgrading the React DevTools project's Babel and Webpack versions in facebook/react-devtools#1235, and we're just now encountering it because we haven't released the react-devtools-core package since then.

I just published react-devtools-core v3.5.1. Can anyone let me know if this resolves the issue? (I'm unable to repro the original reported issue so it's hard for me to verify the fix.)

@davideddr
Copy link

Now it works fine for me creating a new project.
Thank you @bvaughn 👍

@bvaughn
Copy link
Contributor

bvaughn commented Jan 4, 2019

Yay! Thanks for verifying, @davideddr !

@bvaughn
Copy link
Contributor

bvaughn commented Jan 4, 2019

I'm going to mark this issue as closed for now then. Let's re-open if others are still experiencing problems!

@chuckntaylor
Copy link

I can also verify that the issue is gone. Thank you for the quick fix @bvaughn !

@ck3g
Copy link

ck3g commented Jan 4, 2019

@bvaughn yep works for me as well. (Didn't work before)

@kelset
Copy link
Contributor

kelset commented Jan 4, 2019

(thanks @bvaughn for the quick fix!)

@elanpang
Copy link

elanpang commented Jan 7, 2019

@bvaughn
npm install --save-dev [email protected]
It still not work for me with Rn 0.57.8

@jasonroyle
Copy link

jasonroyle commented Jan 7, 2019

@elanpang

npm install --save-dev [email protected]

You shouldn't have to do this anymore, remove react-devtools-core from your dependencies in package.json and run rm -rf node_modules && npm install this should reinstall the packages and bring the fix in along with them.

@elanpang
Copy link

elanpang commented Jan 8, 2019

@jasonroyle
oh,I understand, it is a depend lib of Rn, and Rn alway pull the latest version, like what @sunnylqm said , right?
Now it real works for me, thank you a lot !

@facebook facebook locked as resolved and limited conversation to collaborators Jan 4, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jan 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests