我想访问__DEV__
中的react-native.config.js
,所以我可以管理一些在开发和生产环境中链接的本机库,例如下面的示例:
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,
},
},
},
};
但是,如果执行此操作,则会出现以下错误:
$ 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.
答案 0 :(得分:-1)
您使用的是哪个版本的Nodejs和NPM?
当项目未正确初始化时,有时可能会发生这种情况。 也许尝试以下方法:
npm install or yarn install
react-native init
react-native run-android