【发布时间】:2019-06-26 03:36:30
【问题描述】:
我刚刚从 RN 0.55.4 升级到 0.59.3 .....现在我收到以下错误:
错误:无法从 ....\node_modules\react-native\Libraries\Utilities\HMRClient.js 解析模块 metro/src/lib/bundle-modules/HMRClient:模块 metro/src/lib/bundle-modules /HMRClient 在 Haste 模块地图中不存在
HMRClient.js 文件确实包含以下要求语句:const MetroHMRClient = require('metro/src/lib/bundle-modules/HMRClient');.....而且我无法在任何地方看到以“metro”开头的路径,所以我想我需要以某种方式添加它。还有另外一条 require 语句如下:const invariant = require('invariant'); ....no file name 'invariant' exists either.
Facebook 说这已在 0.53.0 master 中修复,但看起来像它的背面 https://github.com/facebook/react-native/issues/17742
下面是我的 package.json
{
"name": "xs",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"flow": "flow",
"flow start": "flow start",
"flow stop": "flow stop",
"flow status": "flow status",
"flow coverage": "flow coverage"
},
"dependencies": {
"firebase": "^5.11.1",
"flow": "^0.2.3",
"flow-bin": "^0.65.0",
"prop-types": "^15.6.1",
"react": "16.8.3",
"react-native": "0.59.3",
"react-native-elements": "^0.19.0",
"react-native-google-places-autocomplete": "^1.3.9",
"react-native-maps": "git://github.com/react-native-community/react-native-maps.git#master",
"react-native-switch": "^1.4.0",
"react-native-vector-icons": "^4.5.0",
"react-navigation": "^2.5.5",
"react-redux": "^5.1.0",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"babel-eslint": "^8.2.6",
"babel-preset-flow": "^6.23.0",
"eslint": "^4.9.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0",
"prettier-eslint": "^8.8.2",
"@babel/core": "^7.4.3",
"@babel/runtime": "^7.4.3",
"babel-jest": "^24.7.1",
"jest": "^24.7.1",
"metro-react-native-babel-preset": "^0.53.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
请帮忙!
附言以下建议不起作用
要解决,请尝试以下操作:
1.清除守望者手表:watchman watch-del-all。
2、删除node_modules文件夹:rm -rf node_modules && npm install。
3. 重置 Metro Bundler 缓存:rm -rf /tmp/metro-bundler-cache-* 或 npm start -- --reset-cache。
4. 移除急速缓存:rm -rf /tmp/haste-map-react-native-packager-*.
【问题讨论】:
-
你能去你的
node modules文件夹检查HMRClient.js是否真的存在于上述目录中吗? -
是的,肯定有
标签: react-native