无法解析模块`react`
问题描述:
我克隆https://github.com/oblador/react-native-progress无法解析模块`react`
在例如文件夹:
npm i
react-native run-ios
但我得到了一个错误,这是错误screenshoot链接:Unable to resolve module react
这是代码:
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
Animated,
Easing,
View,
ViewPropTypes,
} from 'react-native';
为什么我的react
模块不能解决,但react native
模块可以吗?
答
实施例有错误构建内部package.json
文件节点的依赖关系
"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.47.2",
"react-native-progress": "file:../" // error
},
以修复
- 内实施例的文件夹运行
npm uninstall react-native-progress
- 卸载运行以后
npm install react-native-progress --save
然后运行你的 示例应用程序正常
但是为什么'https://github.com/react-community/react-native-image-picker/blob/develop/Example/package.json'可以成功运行? – user8661717
react-native-progress has依赖关系,所以它会搜索node_modules,但它会混淆node_modules文件夹在哪里react-native-image-picker没有依赖关系,所以它会顺利运行 –
如果它固定为你考虑接受答案:) –