React native “无法解决”@react导航/本机“;从「;App.js";-反应本机+;如何解决?

React native “无法解决”@react导航/本机“;从「;App.js";-反应本机+;如何解决?,react-native,react-navigation,mobile-development,react-navigation-stack,stack-navigator,React Native,React Navigation,Mobile Development,React Navigation Stack,Stack Navigator,未定义无法从App.js解析模块@react-navigation/native:@react-navigation/native在项目中找不到 如果确定模块存在,请尝试以下步骤: 1. Clear watchman watches: watchman watch-del-all 2. Delete node_modules: rm -rf node_modules and run yarn install 3. Reset Metro's cache: yarn start --rese

未定义无法从
App.js
解析模块
@react-navigation/native
:@react-navigation/native在项目中找不到

如果确定模块存在,请尝试以下步骤:

 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules: rm -rf node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
- node_modules\react-native\Libraries\Utilities\HMRClient.js:307:41 in showCompileError
- node_modules\react-native\Libraries\Utilities\HMRClient.js:228:26 in client.on$argument_1
- node_modules\eventemitter3\index.js:181:39 in emit
- node_modules\metro\src\lib\bundle-modules\WebSocketHMRClient.js:80:20 in _ws.onmessage
- node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent
- node_modules\react-native\Libraries\WebSocket\WebSocket.js:232:27 in _eventEmitter.addListener$argument_1
- node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
* [native code]:null in callFunctionReturnFlushedQueue

Unable to resolve "@react-navigation/native" from "App.js"
Failed building JavaScript bundle.
Unable to resolve "@react-navigation/native" from "App.js"
Failed building JavaScript bundle.
Unable to resolve "@react-navigation/native" from "App.js"
Failed building JavaScript bundle.
> Unable to resolve "@react-navigation/native" from "App.js"
Unable to resolve "@react-navigation/native" from "App.js"
Failed building JavaScript bundle.
Error: Can't find react-native in package.json dependencies
Error: Can't find react-native in package.json dependencies

请帮帮我。
电邮号码:罗伊。sounak01@gmail.com

发生此错误是因为您尚未安装react导航

运行:

如果使用expo:

expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view
还运行:

npm install react-navigation

我通过重新安装/更新这些软件包解决了这个问题

npm install --save react-native-gesture-handler react-native-reanimated react-native-screens
为…耍把戏

npm启动--reset cache

但执行以下操作确实成功:

删除

node_modules&package-lock.json从手机中删除应用程序


最好的解决方案是删除您的node_模块和package-lock.json,然后尝试npm安装,这对我很有用

尝试将这一行添加到您的metro.config.js

sourceExts: ['jsx', 'js', 'ts', 'tsx', 'json'],

是否遵循本入门指南中给出的所有步骤?
npm install --save react-native-gesture-handler react-native-reanimated react-native-screens
run npm start -- --reset-cache
run app
sourceExts: ['jsx', 'js', 'ts', 'tsx', 'json'],