facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.59k stars 24.37k forks source link

Flow cannot resolve module ../../polyfills/error-guard.js. #27248

Closed James-E-Adams closed 4 years ago

James-E-Adams commented 5 years ago

Please let me know if this is more of a flow bug. It's probably something silly I'm missing in the flow config but I haven't been able to work it out yet.

React Native version: 0.61.2

System:
    OS: macOS Mojave 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 160.34 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.2 => 0.61.2

Steps To Reproduce

Run flow.

Snack, code example, screenshot, or link to a repository:

Screen Shot 2019-11-18 at 5 06 00 am

Our flow config:

[declarations]
.*/__generated__/.*

[ignore]
; We fork some components by platform
.*/node_modules/.*/*[.]android.js

; Ignore templates for 'react-native init'
.*/local-cli/templates/.*

; Ignore the website subdir
<PROJECT_ROOT>/website/.*

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
; .*/node_modules/.*/node_modules/fbjs/.*

; Ignore the Dangerfile
<PROJECT_ROOT>/danger/dangerfile.js

; Ignore Vendor iOS Libraries.
<PROJECT_ROOT>/ios/Vendor/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/node_modules/babel-plugin-relay

; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

; Ignore polyfills
.*/Libraries/polyfills/.*

.*/node_modules/react-native-tab-view/.*
.*/node_modules/react-native-amplitude-analytics/.*
.*/node_modules/react-native-linear-gradient/.*
.*/node_modules/react-native-fs/.*
.*/node_modules/react-native-image-picker/.*
.*/node_modules/react-native-safe-area-view/index.js.flow
; .*/node_modules/react-native-firebase/.*
; getServerTime returns a number incorrectly, should be a Date
; https://github.com/invertase/react-native-firebase/pull/1986
; .*/node_modules/react-native-firebase/dist/modules/database/index.js.flow
; new flow version + types for this version of firebase are borked (I think)
.*/node_modules/react-native-firebase/.*

.*/node_modules/radium/.*
.*/node_modules/findup/.*/*.json
.*/node_modules/metro/.*

<PROJECT_ROOT>/config/.*

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*
.*/node_modules/react-native/Libraries/polyfills/.*

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
flow/

[strict]
; Fixes a log from https://github.com/facebook/react-native/blob/master/Libraries/ReactPrivate/ReactNativePrivateInterface.js
unsafe-getters-setters

[lints]
all=error
unsafe-getters-setters=off
untyped-import=off

; Removing this until there is actually a recommended way to resolve:
; https://github.com/facebook/flow/issues/6308
deprecated-type=off

; This can cause types to be too loose, but is rarely a bug. Bit sloppy, but
; $FlowFixMe acceptable on these.
; inexact-spread=warn

[options]
sharedmemory.hash_table_pow=21
emoji=true

include_warnings=true

module.system=haste
module.system.haste.use_name_reducers=true
# get basename
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
# strip .js or .js.flow suffix
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
# strip .ios suffix
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
module.system.haste.paths.blacklist=.*/__tests__/.*
module.system.haste.paths.blacklist=.*/__mocks__/.*
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*

; Allow ?. chaining
esproposal.optional_chaining=enable

munge_underscores=true

module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowExpectedError
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

module.file_ext=.ios.js
module.file_ext=.android.js
module.file_ext=.graphql.js
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json

[version]
^0.105.0
jdmunro commented 5 years ago

I don't have the actual solution for this, but here's a work around if you add this to your flowconfig:

[untyped]

.*/node_modules/react-native/Libraries/vendor/core/ErrorUtils.js
jtnix commented 4 years ago

Try commenting the line after

; Ignore polyfills

.*/Libraries/polyfills/.*

this worked for me, using flow 0.92.0, RN 0.61.5

stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.