lsongdev / lsongdev/node-escpos

examples/star_printer_index.js

Open
#423 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.6k
Forks
443
PR merge metrics
No merged PRs in 30d

Description

examples/star_printer_index.js

async printReceipt() {
const escpos = require('escpos');
escpos.Network = require('escpos-network');
const device = new escpos.Network('192.168.1.48',9100);
const printer = new escpos.Printer(device);

  device.open(function () {
    printer
        .font('a')
        .align("STAR_CA")
        .style('bu')
        .size(1, 1)
        .emphasize()
        .text('The quick brown fox jumps over the lazy dog')
        .cancelEmphasize()
        .align("STAR_LA")
        .text('Hello, am printing')
        .align("STAR_RA")
        .barcode('1234567', 'EAN8')
        .qrimage('https://github.com/song940/node-escpos', function () {
          this.fullCut()
          this.close();
        });
  });
},

am getting this error.. "TypeError: net.Socket is not a constructor"
I read everywhere that via browser I should just forget the TCP support.. is that true? is there any work around to be able to print via ethernet cable? if yes what to do?

Otherwise I think I can go with the usb solution witch I dont prefer.. any help please?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue points to examples/star_printer_index.js and the escpos/escpos-network setup; first reproduce the reported net.Socket is not a constructor error and establish whether it runs in a browser or Node.js. Done means a confirmed Ethernet-printing path is identified, or the browser limitation and supported alternative are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.