1

I want to access __DEV__ in react-native.config.js so I can manage some native libraries linking in the development & production environments like sample bellow:

const VECTOR_ICONS_FONTS_PATH =
  './node_modules/react-native-vector-icons/Fonts';
const VECTOR_FONTS = ['MaterialCommunityIcons.ttf'];

module.exports = {
  assets: ['./src/assets/fonts/nop/nop.ttf'],
  dependencies: {
    'react-native-vector-icons': {
      platforms: {
        ios: null,
        android: null,
      },
      assets: VECTOR_FONTS.map((font) => VECTOR_ICONS_FONTS_PATH + '/' + font),
    },
    'react-native-flipper': {
      platforms: {
        ios: null,
        android: __DEV__ ? undefined : null,
      },
    },
  },
};

But if I do this I get the following error:

$ react-native run-android
error Unrecognized command "run-android".
info Run "react-native --help" to see a list of all available commands.
error Command failed with exit code 1.
hamidfzm
  • 4,595
  • 8
  • 48
  • 80
  • try `npm run android` if the error is same then it may be due to node_modules, try deleting node_modules and package-lock.json and then do `npm install` and try again your command – shubham jha Nov 07 '20 at 22:37
  • I'm not using npm. @shubhamjha & it's not the solution. – hamidfzm Nov 07 '20 at 22:39
  • what are you using then ? could you post your package.json file? – shubham jha Nov 07 '20 at 22:40
  • Create two separate files `staging` and `production`. Then write a script that copy one of these files based on argument that you pass, then override your main `config` file. This is what I am doing, Let me know if you have better solution please. – Pir Shukarullah Shah Nov 14 '20 at 13:00

1 Answers1

-1

What version of Nodejs and NPM are you using?

This can sometimes happen when the project is not initialized properly. Perhaps try the following:

  1. Update NodeJs/NPM if not LTS
  2. Delete the node_modules directory
  3. Run npm install or yarn install
  4. Run react-native init
  5. Run react-native run-android

(Duplicate of react-native run-android is unrecognized)

Sohail
  • 4,506
  • 2
  • 38
  • 42