无法解析模块道具类型,但grep道具类型没有显示任何内容

时间:2017-06-09 09:17:09

标签: react-native

我得到了一个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"
  }
}

我google了一下,似乎prop-types被拆分成一个单独的包,作为PropTypes的替代品,它被React 15.5弃用了。所以我最初的猜测是一些依赖包使用prop-types。但想象一下,当我为整个node_modules树寻找'prop-types'并且在任何地方都没有提到它时,我很惊讶(在更新日志中接受eslint-plugin-react)。

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

2 个答案:

答案 0 :(得分:0)

这回答了我的问题:How do I fix RN suddenly being unable to find local modules (Unable to resolve module)?

结果显示错误中给出的建议实际 是正确的,但我错过了一条错误消息。

答案 1 :(得分:0)

您需要道具类型模块。

 npm install --save prop-types