Ich versuche, node printer von einer Elektron-Anwendung zu verwenden, aber sobald ich die Zeilen hinzufüge, um den Drucker zu verwenden, stürzt die Anwendung ab.Drucken von der Elektronenapplikation
Die Konsole gibt diese: [1] 9860 segmentation fault (core dumped) node_modules/electron-prebuilt/dist/electron.
Dies ist die App Ich renne. Ich habe nur die Druckleitungen an die einfache Anwendung, beispielsweise auf Elektronen Dokumentation:
var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
var printer = require('printer');
// Report crashes to our server.
require('crash-reporter').start();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is GCed.
var mainWindow = null;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform != 'darwin') {
app.quit();
}
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600});
// and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/app/index.html');
// Open the devtools.
mainWindow.openDevTools();
printer.printDirect({data:"print from Node.JS buffer" // or simple String: "some text"
, printer:'HP-Deskjet-F4400-series' // printer name, if missing then will print to default printer
, type: 'TEXT' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
, success:function(jobID){
console.log("sent to printer with ID: "+jobID);
}
, error:function(err){console.log(err);}
});
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});
bin ich etwas fehlt? Ich habe den Node-Drucker selbst ausprobiert und ich habe erfolgreich ein paar Kauderwelsch-Texte gedruckt.
ohne Erfolg haben es geschafft. So passiert es jetzt: 'npm ERR! Fehler beim Installationsskript [email protected] 'node-gyp rebuild'. npm ERR! Dies ist höchstwahrscheinlich ein Problem mit dem Druckerpaket, npm ERR! nicht mit npm selbst. npm ERR! Sagen Sie dem Autor, dass dies auf Ihrem System fehlschlägt: npm ERR! node-gyp rebuild npm ERR! Sie können ihre Informationen erhalten über: npm ERR! npm Besitzer ls Drucker npm ERR! Es gibt wahrscheinlich zusätzliche Logging-Ausgabe oben. – leamasuero
@leamasuero Siehe die Dokumente, gibt es auch einen anderen Weg mit dem Knoten-Gyp. vielleicht hilft das. –