【发布时间】:2018-07-19 06:37:21
【问题描述】:
我尝试使用这个库中的 swiper https://github.com/leecade/react-native-swiper
这是我的依赖项:
"react": 16.3.1,
"react-native": "~0.55.2",
"react-native-swiper": "^1.5.13"
但是当我只是添加这个代码import Swiper from 'react-native-swiper';
我的组件喜欢:
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import Swiper from 'react-native-swiper';
class Welcome extends Component {
render() {
return (
<View>
<Text>Welcome</Text>
</View>
);
}
}
export default Welcome;
即使我不使用<Swiper />,它也会显示错误
错误:
Failed to load bundle
检查我的终端错误显示:
error: bundling failed: Error: While trying to resolve module `react-native-swiper` from file `/Users/huaweb/ReactNativeProject/Huaweb/src/components/Welcome.js`, the package `/Users/huaweb/ReactNativeProject/Huaweb/node_modules/react-native-swiper/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/huaweb/ReactNativeProject/Huaweb/node_modules/react-native-swiper/index.js`. Indeed, none of these files exist:
我不知道However, this package itself specifies amainmodule field that could not be resolved是什么
我想不通。有什么我想念的吗?
任何帮助将不胜感激,在此先感谢。
【问题讨论】:
-
完整的错误信息是什么?
-
我上传了关于我的问题的错误图片。请看一下~
-
我明白了,你的终端是否给你同样的错误,或者它是否显示了你的错误的更多细节?
-
这里有一些可能对你有用的解决方案github.com/facebook/react-native/issues/17685
-
感谢您的帮助,但我无法通过此链接找到解决问题的方法,因此我更新了有关我的问题的终端错误信息。
标签: react-native react-native-swiper