[英]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. expo
和package-lock.json
然后重新安装所有包并使用以下命令启动项目: expo r -c
这应该重置缓存并使项目按预期再次工作。
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.