Closed josegoyo closed 3 years ago
Did you clone this repository and attempted to run this code from it, or did you just copy and paste the example to somewhere else?
Only use npm install @thiagoelg/node-printer
to install library in my node project.
these are my dependencies in package.json
:
"dependencies": {
"@thiagoelg/node-printer": "^0.5.5",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dayjs": "^1.8.28",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"jszpl": "^1.1.0",
"moment": "^2.27.0",
"moment-timezone": "^0.5.31",
"morgan": "^1.10.0"
}
You should fix the way you require the library then.
require("../lib")
will attempt to load the library from the relative path ../lib
, which would work if running this example from this repository, but not on another project.
In your case you should change:
var printer = require("../lib")
, template = "N\nS4\nD15\nq400\nR\nB20,10,0,1,2,30,173,B,\"barcode\"\nP0\n";
to
var printer = require("@thiagoelg/node-printer")
, template = "N\nS4\nD15\nq400\nR\nB20,10,0,1,2,30,173,B,\"barcode\"\nP0\n";
Hi,
I try to use the Zebra print example but I get this error when I run
npm run dev
-Error: Cannot find module '../lib'
.This is my code: