react-native-esc-pos-printer icon indicating copy to clipboard operation
react-native-esc-pos-printer copied to clipboard

Uncaught TypeError: Cannot read properties of undefined (reading 'getConstants') after just using import...

Open WingsDevelopment opened this issue 2 years ago • 3 comments

I have just installed it with: npm i react-native-esc-pos-printer

I am trying this on new react-native project. So I just initialized it with expo init and added import in app.js.

import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View } from "react-native";
import EscPosPrinter, {
  getPrinterSeriesByName,
} from "react-native-esc-pos-printer";

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to ss tart working on your app!</Text>
      <StatusBar style="auto" />
    </View>
  );
}

And then I get this error, am I missing something?

Uncaught TypeError: Cannot read properties of undefined (reading 'getConstants') at ./node_modules/react-native-esc-pos-printer/lib/module/constants.js (constants.ts:16:1) at webpack_require (bootstrap:24:1) at fn (hot module replacement:62:1) at ./node_modules/react-native-esc-pos-printer/lib/module/utils/getPrinterSeriesByName.js (getPrinterLanguage.ts:17:1) at webpack_require (bootstrap:24:1) at fn (hot module replacement:62:1) at ./node_modules/react-native-esc-pos-printer/lib/module/utils/index.js (getPrinterSeriesByName.ts:12:1) at webpack_require (bootstrap:24:1) at fn (hot module replacement:62:1) at ./node_modules/react-native-esc-pos-printer/lib/module/index.js (constants.ts:353:1)

WingsDevelopment avatar Aug 13 '23 10:08 WingsDevelopment

Are you running it on Expo Go, or development client?

tolypash avatar Aug 28 '23 09:08 tolypash

@tolypash Does that make a diffference?

AnointingMax avatar Sep 26 '23 15:09 AnointingMax

@AnointingMax Yes, Expo Go only has a set of native dependencies installed, so if you want this package you need to run your app on expo development client where all the native dependencies required by your app are bundled together

tolypash avatar Sep 26 '23 15:09 tolypash