问题 反应本机和流错误消息


嗨,我试图用React Native做一些你好的世界。 我创建项目'react-native init'更改'.flowconfig'中的流版本。

跑流,它给了我153个错误 node_modules 文件夹就好 node_modules/react-native/Libraries

有没有人遇到同样的问题?


4786
2018-03-16 08:45


起源



答案:


我遇到了同样的问题。您需要执行两个步骤:

1.比较你的 .flowconfig 使用此文件并添加您缺少的行:

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

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

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

; 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
.*/Libraries/react-native/ReactNative.js

<PROJECT_ROOT>/node_modules/.*
<PROJECT_ROOT>/libdefs.js
.*/__tests__/.*

[include]

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

创造 libdefs.js 进入根文件夹。它应该看起来像这样:

declare module 'react-native' { declare var exports: any; }
declare module 'jest' { declare var exports: any; }

另外,声明所有模块流引发错误(例如 'mobx'  - 我知道这可能有点令人沮丧,但必须要做到)


14
2018-03-16 09:35



谢谢,它摆脱了大部分错误,但下面有一个。 This modules resolves to "<<PROJECT_ROOT>>/../../node_modules/react/package.json", which is outside both your root directory and all of the entries in the [include] section of your .flowconfig. You should either add this directory to the [include] section of your .flowconfig, move your .flowconfig file higher in the project directory tree, or move this package under your Flow root directory.: /Users/*********/ReactNative/ToDoList/index.ios.js:18  我无法确定要为此添加哪个模块。 - moka2258
你的第二步不会破坏从react-native导入的任何东西的类型检查吗?你可以写 <Text nonExistantProp="purple-panda"></Text> 和它一起流动将是笨拙的。 - Jony Thrive
如果我错了,请纠正我,但这种做法让我感到:“排除一切并列入白名单”va。 “包括一切和黑名单”。我觉得它有可能危及node_modules的流类型的价值。我说这没有一个明确更好的解决方案。如果我能搞清楚会更新。 - leggomuhgreggo


答案:


我遇到了同样的问题。您需要执行两个步骤:

1.比较你的 .flowconfig 使用此文件并添加您缺少的行:

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

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

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

; 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
.*/Libraries/react-native/ReactNative.js

<PROJECT_ROOT>/node_modules/.*
<PROJECT_ROOT>/libdefs.js
.*/__tests__/.*

[include]

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

创造 libdefs.js 进入根文件夹。它应该看起来像这样:

declare module 'react-native' { declare var exports: any; }
declare module 'jest' { declare var exports: any; }

另外,声明所有模块流引发错误(例如 'mobx'  - 我知道这可能有点令人沮丧,但必须要做到)


14
2018-03-16 09:35



谢谢,它摆脱了大部分错误,但下面有一个。 This modules resolves to "<<PROJECT_ROOT>>/../../node_modules/react/package.json", which is outside both your root directory and all of the entries in the [include] section of your .flowconfig. You should either add this directory to the [include] section of your .flowconfig, move your .flowconfig file higher in the project directory tree, or move this package under your Flow root directory.: /Users/*********/ReactNative/ToDoList/index.ios.js:18  我无法确定要为此添加哪个模块。 - moka2258
你的第二步不会破坏从react-native导入的任何东西的类型检查吗?你可以写 <Text nonExistantProp="purple-panda"></Text> 和它一起流动将是笨拙的。 - Jony Thrive
如果我错了,请纠正我,但这种做法让我感到:“排除一切并列入白名单”va。 “包括一切和黑名单”。我觉得它有可能危及node_modules的流类型的价值。我说这没有一个明确更好的解决方案。如果我能搞清楚会更新。 - leggomuhgreggo


发现了这个 问题 建议更新flowconfig以使用 来自create-react-native-app的最新版本。似乎对我有用。


0
2018-03-17 21:30