Skip to content

Page cannot access when use "esc-pos-encoder-ionic"  #8

@KApoNG21

Description

@KApoNG21

Hi, I try to use "esc-pos-encoder-ionic" NPM package in my Ionic project.
When I try to open the page which use the service contains the imported library I have this error:

ERROR Error: Uncaught (in promise): ReferenceError: Cannot access 'HomePageModule' before initialization
ReferenceError: Cannot access 'HomePageModule' before initialization

Related code:

import EscPosEncoder from 'esc-pos-encoder-ionic';
//----
createTicket(){
const encoder = new EscPosEncoder();
const result = encoder.initialize();

result
  .align('center')
  .newline()
  .line('Congratulation, print success')
  .line('IP : ' + '192.168.1.1')
  .line('Port : ' + '9100')
  .newline()
  .newline()
  .newline()
  .newline()
  .newline()
  .newline()
  .cut();

const resultByte = result.encode();

// send byte code into the printer
socket.open(
  '192.168.1.1',
  '9100',
  () => {
    socket.write(resultByte, () => {
      socket.shutdownWrite();
    });
  },
  (err) => {
    console.error(err);
  }
);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions