bolan9999 / react-native-largelist

The best large list component for React Native.
https://bolan9999.github.io/react-native-largelist/
MIT License
2.32k stars 261 forks source link

在0.6.3无法使用提示错误 #441

Closed Carson-czl closed 3 years ago

Carson-czl commented 3 years ago

2021-03-10 11:50:46.977 31576-31704/com.haiyou.bd E/unknown:ReactNative: Unable to download JS bundle com.facebook.react.common.DebugServerException: The development server returned response error code: 500

URL: http://localhost:8081/index.bundle?platform=android&dev=true&minify=false

Body:
{"originModulePath":"node_modules\\react-native-spring-scrollview\\SpringScrollView.js","targetModuleName":"react-native/lib/TextInputState","message":"Unable to resolve module `react-native/lib/TextInputState` from `node_modules\\react-native-spring-scrollview\\SpringScrollView.js`: react-native/lib/TextInputState could not be found within the project.\n\nIf you are sure the module exists, try these steps:\n 1. Clear watchman watches: watchman watch-del-all\n 2. Delete node_modules: rm -rf node_modules and run yarn install\n 3. Reset Metro's cache: yarn start --reset-cache\n 4. Remove the cache: rm -rf /tmp/metro-*","errors":[{"description":"Unable to resolve module `react-native/lib/TextInputState` from `node_modules\\react-native-spring-scrollview\\SpringScrollView.js`: react-native/lib/TextInputState could not be found within the project.\n\nIf you are sure the module exists, try these steps:\n 1. Clear watchman watches: watchman watch-del-all\n 2. Delete node_modules: rm -rf node_modules and run yarn install\n 3. Reset Metro's cache: yarn start --reset-cache\n 4. Remove the cache: rm -rf /tmp/metro-*"}],"name":"Error","stack":"Error: Unable to resolve module `react-native/lib/TextInputState` from `node_modules\\react-native-spring-scrollview\\SpringScrollView.js`: react-native/lib/TextInputState could not be found within the project.\n\nIf you are sure the module exists, try these steps:\n 1. Clear watchman watches: watchman watch-del-all\n 2. Delete node_modules: rm -rf node_modules and run yarn install\n 3. Reset Metro's cache: yarn start --reset-cache\n 4. Remove the cache: rm -rf /tmp/metro-*\n    at ModuleResolver.resolveDependency (E:\\WEB_czl\\lzsp\\lzsp\\node_modules\\metro\\src\\node-haste\\DependencyGraph\\ModuleResolution.js:186:15)\n    at ResolutionRequest.resolveDependency (E:\\WEB_czl\\lzsp\\lzsp\\node_modules\\metro\\src\\node-haste\\DependencyGraph\\ResolutionRequest.js:52:18)\n    at DependencyGraph.resolveDependency (E:\\WEB_czl\\lzsp\\lzsp\\node_modules\\metro\\src\\node-haste\\DependencyGraph.js:287:16)\n    at Object.resolve (E:\\WEB_czl\\lzsp\\lzsp\\node_modules\\metro\\src\\lib\\transformHelpers.js:267:42)\n    at E:\\WEB_czl\\lzsp\\lzsp\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:434:31\n    at Array.map (<anonymous>)\n    at resolveDependencies (E:\\WEB_czl\\lzsp\\lzsp\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:431:18)\n    at E:\\WEB_czl\\lzsp\\lzsp\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:275:33\n    at Generator.next (<anonymous>)\n    at asyncGeneratorStep (E:\\WEB_czl\\lzsp\\lzsp\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:87:24)"}

1615348263(1)

我项目里的依赖

{ "name": "xxx", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android --main-activity=MainActivity", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "dependencies": { "@react-native-community/async-storage": "^1.12.1", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^5.9.9", "@react-native-community/viewpager": "^4.2.2", "@react-navigation/bottom-tabs": "^5.11.2", "@react-navigation/material-top-tabs": "^5.3.10", "@react-navigation/native": "^5.8.10", "@react-navigation/stack": "^5.12.8", "axios": "^0.21.1", "crypto-js": "^3.3.0", "react": "16.13.1", "react-native": "0.63.3", "react-native-gesture-handler": "^1.9.0", "react-native-idle-timer": "^2.1.6", "react-native-image-picker": "^3.1.4", "react-native-linear-gradient": "^2.5.6", "react-native-orientation-locker": "^1.2.0", "react-native-reanimated": "^1.13.2", "react-native-safe-area-context": "^3.1.9", "react-native-screens": "^2.15.0", "react-native-largelist-v3": "^3.0.14", "react-native-spring-scrollview": "^2.0.21", "react-native-tab-view": "^2.15.2", "react-native-update": "^5.10.0", "react-native-video": "^5.1.1", "react-redux": "^7.2.2", "redux": "^4.0.5", "redux-saga": "^1.1.3", "rn-fetch-blob": "^0.12.0" }, "devDependencies": { "@babel/core": "^7.8.4", "@babel/runtime": "^7.8.4", "@react-native-community/eslint-config": "^1.1.0", "@types/crypto-js": "^4.0.1", "@types/jest": "^25.2.3", "@types/react-native": "^0.63.2", "@types/react-native-video": "^5.0.3", "@types/react-redux": "^7.1.12", "@types/react-test-renderer": "^16.9.2", "@typescript-eslint/eslint-plugin": "^2.27.0", "@typescript-eslint/parser": "^2.27.0", "babel-jest": "^25.1.0", "eslint": "^6.5.1", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.59.0", "react-test-renderer": "16.13.1", "typescript": "^3.8.3" }, "jest": { "preset": "react-native", "moduleFileExtensions": [ "ts", "tsx", "js", "jsx", "json", "node" ] } }

edisonlao commented 3 years ago

在项目根目录添加scripts/react-scrollview-fix.js

const fs = require("fs");

try {

var rootDir = process.cwd();

var file = ${rootDir}/node_modules/react-native-spring-scrollview/SpringScrollView.js; var data = fs.readFileSync(file, "utf8"); var dataFix = 'react-native/Libraries/Components/TextInput/TextInputState';

if (data.indexOf(dataFix) !== -1) { throw "> Already fixed"; }

var result = data.replace( /react-native\/lib\/TextInputState/g, dataFix, ); fs.writeFileSync(file, result, "utf8");

} catch (error) { console.error(error); }

然后在package.json的scripts里面加上 "postinstall": "node scripts/react-scrollview-fix.js"

最后执行一次 npm run postinstall就行了

bolan9999 commented 3 years ago

500是代码有问题或者RN问题吧