envinfo icon indicating copy to clipboard operation
envinfo copied to clipboard

fullTree gets confused by spurious package.json files

Open mhorowitz opened this issue 5 years ago • 1 comments

https://github.com/react-native-community/cli/blob/master/packages/cli/src/commands/info/info.js#L27 uses envinfo to display versions of packages use by a RN app. You can see that '@react-native-community/cli' is in that list, but it isn't printed by react-native info, because the dependency is not in the top-level package.json file. I added {fullTree:true} options to the call in info.js, but when I did that I got more than I bargained for:

  npmPackages:
    @react-native-community/cli:  2.9.0
    HelloWorld:  0.0.1
    Sample:  0.0.1
    hermes-inspector-msggen:  1.0.0
    react: 16.8.6 => 16.8.6
    react-animated:  0.1.0
    react-native: 0.60.5 => 0.60.5

The extra "packages" listed here come from package.json files which are in subdirectories of node_modules/react-native.

It seems that utils.getAllPackageJsonPaths is a bit too eager in generating its list of package.json files, including files which aren't actually in the app's recursive dependencies.

mhorowitz avatar Sep 04 '19 13:09 mhorowitz

@mhorowitz thanks for reporting this. I've created a repo here to reproduce https://github.com/ryhinchey/envinfo-react-native-example

When I add fullTree: true and run npx react-native info, this is my output:

$ npx react-native info
info Fetching system and libraries information...
System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 2.61 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 13.9.0 - ~/.nvm/versions/node/v13.9.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.13.7 - ~/.nvm/versions/node/v13.9.0/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.9.1 - /Users/ryhinchey/.rvm/gems/ruby-2.7.1/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 11.4/11E146 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_77 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli:  4.7.0 
    HelloWorld:  0.0.1 
    hermes-inspector-msggen:  1.0.0 
    react: 16.11.0 => 16.11.0 
    react-animated:  0.1.0 
    react-native: 0.62.2 => 0.62.2 
  npmGlobalPackages:
    *react-native*: Not Found

Given this is reproducible, I'll look into what we can do to fix this

ryhinchey avatar Apr 16 '20 02:04 ryhinchey