简体   繁体   English

如何修复无法从“node_modules\\react-navigation-stack\\lib\\module\\views\\StackView\\StackViewCard.js”解析“react-native-screens”?

[英]How to fix Unable to resolve "react-native-screens" from "node_modules\react-navigation-stack\lib\module\views\StackView\StackViewCard.js"?

I used below command for react app routes.我使用下面的命令来响应应用程序路由。

npm i react-native-router-flux --save npm i react-native-router-flux --save

Then i restart npm by "npm start" and get this error然后我通过“npm start”重新启动 npm 并收到此错误

Unable to resolve "react-native-screens" from "node_modules\\react-navigation-stack\\lib\\module\\views\\StackView\\StackViewCard.js" Failed building JavaScript bundle.无法从“node_modules\\react-navigation-stack\\lib\\module\\views\\StackView\\StackViewCard.js”解析“react-native-screens” 构建 JavaScript 包失败。

How can fix this error?如何修复此错误? I also updated npm.我也更新了 npm。

This is package.json file这是 package.json 文件

         {
          "main": "node_modules/expo/AppEntry.js",
          "scripts": {
          "start": "expo start",
          "android": "expo start --android",
          "ios": "expo start --ios",
          "web": "expo start --web",
          "eject": "expo eject"
         },
         "dependencies": {
           "expo": "~36.0.0",
           "react": "~16.9.0",
           "react-dom": "~16.9.0",
           "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
           "react-native-router-flux": "^4.2.0",
           "react-native-web": "~0.11.7"
          },
          "devDependencies": {
            "babel-preset-expo": "~8.0.0",
            "@babel/core": "^7.0.0"
           },
          "private": true
          }

I used react native official navigation.我使用了 React Native 官方导航。 It really helpful and easy to use.它非常有用且易于使用。 Visit https://facebook.github.io/react-native/docs/navigation访问https://facebook.github.io/react-native/docs/navigation

I had the same issue.我遇到过同样的问题。 Noticed that package.json in the repo is missing react-native-screens from the dependencies.注意到 repo 中的 package.json 缺少依赖项中的 react-native-screens。

npm i react-native-screens npm i react-native-screens

This is because of the new react-navigation changes.这是因为新的反应导航变化。 Doing a npm install right now is installing the latest versions instead of the previous versions现在进行 npm install 是安装最新版本而不是以前的版本

You should clear the cache by removing node_module , .您应该通过删除node_module来清除缓存。 expo and package-lock.json and then reinstall all the packages and start the project by using the following command: expo r -c which should reset the cache and make the project work again as intended. expopackage-lock.json然后重新安装所有包并使用以下命令启动项目: expo r -c这应该重置缓存并使项目按预期再次工作。

More Info 更多信息

Installing following two,安装以下两个,

npm install --save @react-native-community/masked-view
npm install react-native-safe-area-context

it is work for me这对我有用

or use,或使用,

npm install @react-navigation/native

for install 'react-navigation'用于安装“反应导航”

I got a similar error after upgrading from React Navigation V3 to V4.从 React Navigation V3 升级到 V4 后,我遇到了类似的错误。

Simply doing简单地做

npm i react-native-screens

solved the problem for me.为我解决了这个问题。

Install the following dependencies.安装以下依赖项。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从“node_modules\react-navigation-stack\lib\module\navigators\createStackNavigator.js”解析“react-navigation” - Unable to resolve “react-navigation” from “node_modules\react-navigation-stack\lib\module\navigators\createStackNavigator.js” 无法解析“../SecondApp\\node_modules\\react-navigation-stack\\lib\\module\\navigators”中的“react-navigation” - Can't resolve 'react-navigation' in '../SecondApp\node_modules\react-navigation-stack\lib\module\navigators' 无法从“App.js”解析“react-navigation-stack” - Unable to resolve “react-navigation-stack” from “App.js” 无法从 `node_modules\react-redux\lib\connect\mapDispatchToProps.js` 解析模块 `../../../../src/redux` - Unable to resolve module `../../../../src/redux` from `node_modules\react-redux\lib\connect\mapDispatchToProps.js` 无法使用 react-navigation-stack 解析依赖关系树 - Unable to resolve dependency tree with react-navigation-stack 无法解析模块“react-navigation-stack”找不到解决方案 - Unable to resolve module 'react-navigation-stack' Can't find a solution 无法从“node_modules/react-native/Libraries/ART/ARTSerializablePath.js”解析“art/core/class.js” - Unable to resolve "art/core/class.js" from "node_modules/react-native/Libraries/ART/ARTSerializablePath.js" 急速模块 map 中不存在模块“react-native-screens” - Module `react-native-screens` does not exist in the Haste module map 无法从“screens\SignUpScreen.js”解析“react-native-paper/lib/typescript/src/components/MaterialCommunityIcon” - Unable to resolve "react-native-paper/lib/typescript/src/components/MaterialCommunityIcon" from "screens\SignUpScreen.js" 如何在 react-navigation v4 中使用 react-native-screens? - How to use react-native-screens with react-navigation v4?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM