在Windows上运行,运行“ npm install --save redux”和“ npm install --save react-redux”,然后将它们链接起来。尝试在Android模拟器上构建JavaScript捆绑包时,Expo显示错误“无法从“ App.js”解析“ react-redux””。我的package.json当前看起来像这样:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject"
},
"dependencies": {
"@babel/runtime": "^7.3.4",
"expo": "^32.0.0",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-navigation": "^3.3.0",
"react-redux": "^6.0.1",
"redux": "^4.0.1"
},
"devDependencies": {
"babel-preset-expo": "^5.0.0"
},
"private": true
}
关于如何解决的任何提示?我通常在Mac上工作,这是我第一次看到这些问题。
编辑:添加了App.js
import React from 'react';
import { StyleSheet, Text, View, Picker, TouchableOpacity } from 'react-native';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import ChargingInfo from './ChargingInfo';
import VehicleSelect from './VehicleSelect';
import ChargingProfile from './ChargingProfile';
const AppNavigator = createStackNavigator({
Home: {screen: VehicleSelect},
ChargingInfo: {screen: ChargingInfo},
ChargingProfile: {screen: ChargingProfile}
});
// const initialState = {
// }
// const reducer = (state = initialState, action) => {
// }
// const store = createStore(reducer)
export default createAppContainer(AppNavigator);
// export default class App extends React.Component {
// render() {
// return (
// <Provider store={store}>
// <AppNavigator />
// </Provider>
// );
// }
// }
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
}
});