代码之家  ›  专栏  ›  技术社区  ›  Benjamin Heinke

React Native Error:您当前使用的是NODE_ENV==='production'使用Redux的小型代码

  •  0
  • Benjamin Heinke  · 技术社区  · 6 年前

    这里是我的代码:

    webpack.config.js

     var path = require('path');
    
    module.exports = {
      mode: 'production',
      entry: "./App.js",
      output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js'
      },
    };
    

    应用程序js

    import * as React from "react";
    import { Provider } from "react-redux";
    import { createStore  } from "redux";
    import { reducers } from "./reducers";
    
    import { Drawer } from "./Navigation";
    import LibraryReducer from "./reducers/LibraryReducer";
    
    export default class App extends React.Component {
      render() {
        const store = createStore(LibraryReducer)
        return (
          <Provider store={store}>
            <Drawer />
          </Provider>
    
        );
      }
    }
    

    {
      "name": "empty-project-template",
      "main": "node_modules/expo/AppEntry.js",
      "private": true,
      "scripts": {
        "start": "webpack",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "eject": "expo eject",
        "build": "webpack --config webpack.config.js"
      },
      "dependencies": {
        "@babel/core": "^7.0.0",
        "@babel/plugin-transform-react-jsx-source": "^7.0.0",
        "@expo/vector-icons": "^8.0.0",
        "babel-preset-expo": "^5.0.0",
        "create-webpack-config": "^0.2.1",
        "db": "^1.1.1",
        "expo": "^31.0.0",
        "expo-asset": "^1.0.2",
        "expo-constants": "^1.1.0",
        "expo-core": "^1.2.0",
        "expo-file-system": "^1.1.0",
        "expo-font": "^1.1.0",
        "expo-react-native-adapter": "^1.0.2",
        "loose-envify": "^1.4.0",
        "metro-react-native-babel-preset": "^0.50.0",
        "native-base": "^2.8.0",
        "pirates": "^4.0.0",
        "react": "16.5.0",
        "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
        "react-native-calendars": "^1.20.0",
        "react-native-dialog": "^5.3.0",
        "react-native-elements": "^0.19.1",
        "react-native-haptic-feedback": "^1.2.0",
        "react-native-simple-dialogs": "^0.4.1",
        "react-native-swipeout": "^2.3.6",
        "react-native-vector-icons": "^5.0.0",
        "react-native-view-overflow": "^0.0.3",
        "react-navigation": "^2.12.1",
        "react-redux": "^6.0.0",
        "redux": "^4.0.1",
        "watchman": "^1.0.0"
      },
      "devDependencies": {
        "webpack": "^4.27.1",
        "webpack-cli": "^3.1.2"
      }
    }
    

    巴别尔克

    {
      "presets": ["module:metro-react-native-babel-preset"]
    }
    

    任何想法都是受欢迎的。

    0 回复  |  直到 6 年前
        1
  •  1
  •   Nabha Cosley    5 年前

    您可能早就解决了这个问题,但我也遇到了同样的问题,通过将minify设置更改为this line in来解决它 .expo/settings.json :

    "minify": false
    

    true .