无法从“App.js”解析“@react-navigation/native”- React Native +如何解决?

5jvtdoz2  于 2022-12-04  发布在  React
关注(0)|答案(8)|浏览(199)

undefined无法从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

请帮助我。电子邮件ID:网站名称gmail.com

tquggr8v

tquggr8v1#

npm install @react-navigation/native

如果使用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
6za6bjd0

6za6bjd02#

发生此错误的原因是您尚未安装react-navigation。
运行时间:

npm install react-navigation
npm start -- --reset-cache
hgtggwj0

hgtggwj03#

最好的解决方案是删除您的node_modules和package-lock.json并尝试npm安装,它对我很有效

hfsqlsce

hfsqlsce4#

尝试将此行添加到metro.config.js

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

tkqqtvp15#

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

npm install --save react-native-gesture-handler react-native-reanimated react-native-screens

对...起作用
npm start -- --reset-cache
但执行以下操作确实成功:
删除
node_modules & package-lock.json从手机中删除应用程序

run npm start -- --reset-cache
run app
avwztpqn

avwztpqn6#

此外,你必须重新启动你的应用程序,做npm运行...启动一个新的服务器,如果你正在使用expo。

nr9pn0ug

nr9pn0ug7#

我一直在同一个问题上卡住了一整天,最后删除packagelock.json和节点模块文件夹与使用
尝试重置该高速缓存
在NPM启动之后
最后运行:npxReact-原生运行-安卓
现在所有的文件都将被重建,你的导航容器应该可以工作了

iibxawm4

iibxawm48#

此错误是由于缓存过时造成的。若要修复此问题,请运行:npm start -c //如果您使用expo
如果不使用expo,请运行:npxReact-本机启动-重置-缓存

相关问题