tr3v3r / react-native-esc-pos-printer

An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android
MIT License
137 stars 64 forks source link

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

Open WingsDevelopment opened 10 months ago

WingsDevelopment commented 10 months ago

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)

tolypash commented 10 months ago

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

AnointingMax commented 9 months ago

@tolypash Does that make a diffference?

tolypash commented 9 months ago

@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