gpt4 book ai didi

react-native - 无法解析模块 prop-types,但 grep prop-types 没有显示任何内容

转载 作者:行者123 更新时间:2023-12-02 03:54:19 24 4
gpt4 key购买 nike

我得到了一个 iOS 应用程序的源代码(从 2016 年底开始),现在我正在尝试在模拟器中构建和运行它。我刚刚在学习 React Native。

完整的错误信息在这里:

Unable to resolve module prop-types from /Users/raarts/work/MobileApp/app/node_modules/react-redux/lib/components/Provider.js: Module does not exist in the module map or in these directories:
/Users/raarts/work/MobileApp/app/node_modules/react-redux/node_modules
, /Users/raarts/work/MobileApp/app/node_modules

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.

RCTFatal
-[RCTBatchedBridge stopLoadingWithError:]
__25-[RCTBatchedBridge start]_block_invoke_2
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
UIApplicationMain
main
start

当然,我确实尝试了建议的解决方案,但没有奏效。我的问题是:我检查了 Provider.js,但该文件中甚至没有出现“prop-types”这个词。

这是 package.json:

{
"name": "app",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"lint": "./node_modules/.bin/eslint index*.js src __tests__",
"test": "jest"
},
"dependencies": {
"google-libphonenumber": "^2.0.10",
"prop-types": "^15.5.10",
"react": "15.4.2",
"react-native": "0.40.0",
"react-native-contacts": "^0.7.1",
"react-native-debug-stylesheet": "^0.1.1",
"react-native-device-info": "^0.9.7",
"react-native-i18n": "^0.1.1",
"react-native-keyboard-aware-scroll-view": "^0.2.8",
"react-native-modalbox": "^1.3.9",
"react-native-router-flux": "^3.36.0",
"react-native-scrollable-tab-view": "^0.7.0",
"react-native-send-intent": "^1.0.13",
"react-redux": "^4.4.5",
"redux": "^3.6.0",
"redux-actions": "^0.12.0",
"redux-thunk": "^2.1.0"
},
"jest": {
"preset": "react-native"
},
"devDependencies": {
"babel-eslint": "^7.0.0",
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"chai": "^3.5.0",
"eslint": "^3.12.1",
"eslint-plugin-react": "^6.4.1",
"eslint-plugin-react-native": "^2.2.1",
"fetch-mock": "^5.6.0",
"jest": "18.1.0",
"jest-react-native": "16.0.0",
"react-test-renderer": "15.4.2",
"redux-mock-store": "^1.2.1"
}
}

我四处搜索,似乎 prop-types 被拆分成一个单独的包,作为 PropTypes 的替代品,PropTypes 在 React 15.5 中被弃用。所以我最初的猜测是一些依赖包正在使用 prop-types。但是想象一下,当我为“prop-types”搜索整个 node_modules 树时我会感到惊讶,但在任何地方都没有提到它(在 eslint-plugin-react 的变更日志中接受)。

所以现在我很困惑。这里发生了什么?

最佳答案

你需要 prop-types 模块。

 npm install --save prop-types

关于react-native - 无法解析模块 prop-types,但 grep prop-types 没有显示任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44453932/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com