无法解析模块 react-native-navbar
Posted
技术标签:
【中文标题】无法解析模块 react-native-navbar【英文标题】:Unable to resolve module react-native-navbar 【发布时间】:2017-05-31 04:38:09 【问题描述】:我无法安装组件,因为我收到此错误:
npm install react-native-side-menu
Rdemo@0.0.1 /home/mss/Desktop/cakenew25_aug/MagentoLatest/Rdemo
+-- UNMET PEER DEPENDENCY react@16.0.0-alpha.6
`-- react-native-side-menu@0.20.1
npm WARN react-native-selectbox@0.1.2 requires a peer of react@>15.0 but none was installed.
npm WARN react-static-container@1.0.1 requires a peer of react@^0.13.0 || ^0.14.0 || ^15.0.0 but none was installed.
我正在尝试在我的 react native 演示中实现侧边菜单。我是这个平台的新手和自学者。 我在这个演示中使用 react-native-router-flux 架构。
我从下面的链接中获得了侧边菜单实现的示例:-
https://reacttuts.blogspot.in/2016/06/side-menu-component-for-react-native.html?showComment=1496152015774#c5969922046557572516
我尝试了以下命令来消除此错误,但没有成功:-
npm install npm@latest -g
npm prune
npm install --save react@16.0.0-alpha.6
React 原生版本信息:-
react-native-cli: 2.0.1
react-native: 0.44.0
这是我的 Package.json:-
"name": "Rdemo",
"version": "0.0.1",
"private": true,
"scripts":
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
,
"dependencies":
"react": "^16.0.0-alpha.6",
"react-native": "0.44.0",
"react-native-check-box": "^1.0.4",
"react-native-drawer": "^2.3.0",
"react-native-easy-toast": "^1.0.6",
"react-native-flexi-radio-button": "^0.2.0",
"react-native-router-flux": "^3.38.0",
"react-native-selectbox": "^0.1.2",
"react-native-vector-icons": "^4.1.1",
"react-native-web-service-handler": "^1.0.2"
,
"devDependencies":
"babel-jest": "20.0.3",
"babel-preset-react-native": "1.9.2",
"jest": "20.0.3",
"react-test-renderer": "16.0.0-alpha.6"
,
"jest":
"preset": "react-native"
npm 详细信息:-
npm list --depth=0
Rdemo@0.0.1 /home/mss/Desktop/cakenew25_aug/MagentoLatest/Rdemo
+-- babel-jest@20.0.3
+-- babel-preset-react-native@1.9.2
+-- jest@20.0.3
+-- UNMET PEER DEPENDENCY react@16.0.0-alpha.6
+-- react-native@0.44.0
+-- react-native-check-box@1.0.4
+-- react-native-drawer@2.3.0
+-- react-native-easy-toast@1.0.6
+-- react-native-flexi-radio-button@0.2.0
+-- react-native-router-flux@3.39.2
+-- react-native-selectbox@0.1.2
+-- react-native-vector-icons@4.2.0
+-- react-native-web-service-handler@1.0.2
`-- react-test-renderer@16.0.0-alpha.6
npm ERR! peer dep missing: react@>15.0, required by react-native-selectbox@0.1.2
npm ERR! peer dep missing: react@^0.13.0 || ^0.14.0 || ^15.0.0, required by react-static-container@1.0.1
Node version :- v6.9.1
npm version :- v3.10.8
这是我的错误截图:-
任何帮助, 谢谢
【问题讨论】:
尝试使用yarn安装包 @KimHau,你的意思是 yarn add react@16.0.0-alpha.6 吗? @KimHau , yarn add react-native-side-menu ? 是的纱线添加 react-native-side-menu 收到此错误:- 错误:[Errno 2] 没有这样的文件或目录:'add' 【参考方案1】:react-native-side-menu 需要 react 16.0.0-alpha.6 才能工作。 为此,请在位于根目录的项目文件夹中找到 package.json 文件。打开它并找到 react(在依赖项字典中),将值编辑为“16.0.0-alpha.6”,保存然后
rm -rf node_modules/
npm install --save
这将安装在你的 package.json 中找到的所有依赖项,现在将安装所需的 react 版本。此过程可用于任何包。
【讨论】:
在你的项目目录下找不到模块,可能是因为包是全局安装的,这样做,进入你的项目目录,删除所有节点模块,然后 npm install --节省。并从您的项目文件夹中,react-native run-android。让我知道你得到了什么输出 我应该删除节点模块文件夹吗?还是里面的文件夹? 整个节点模块文件夹,从你的根目录执行 rm -rf node_modules/ 就可以了 仍然遇到同样的问题,我运行两个命令 rm -rf node_modules/ 然后 npm install --save。 好的,可能是库没有正确链接。尝试 react-native 链接 react-native-side-menu【参考方案2】:您是否尝试过使用 sudo 进行安装。我认为这是一种权限问题。
【讨论】:
你好@Anuj,是的,我也尝试过 Sudo,它仍然给出同样的错误。以上是关于无法解析模块 react-native-navbar的主要内容,如果未能解决你的问题,请参考以下文章