question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'once' of undefined

See original GitHub issue

When start the project by express.

/Users/lxxyx/Desktop/own/yun-type/node_modules/electron-pdf/lib/index.js:32 electronApp.once(‘ready’, () => { ^

TypeError: Cannot read property ‘once’ of undefined at PDFExporter.start (/Users/lxxyx/Desktop/own/yun-type/node_modules/electron-pdf/lib/index.js:32:16) at Object.<anonymous> (/Users/lxxyx/Desktop/own/yun-type/js_server/app.js:22:10) at Module._compile (module.js:570:32) at Object.Module._extensions…js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:509:3

import * as express from 'express'
import * as bodyParser from 'body-parser'
const ElectronPDF = require('electron-pdf')

const app = express()
app.use(bodyParser.json())

const exporter = new ElectronPDF()

app.post('/pdfexport', (req, res) => {
    const source:string = req.body.source
    exporter.createJob(source, './')
    .then((job) => {
        job.render()
        job.on('job-complete', (r) => {
            console.log('pdf files:', r.results)
        })
    })
})

exporter.on('charged', () => {
    //Only start the express server once the exporter is ready
    app.listen(3000)
})

exporter.start()

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
Lxxyxcommented, Dec 9, 2016

@codecounselor Thank you. I run it at Node but not electron.

0reactions
codecounselorcommented, Sep 7, 2017

Yes it runs on windows, but you have to run npm install from the target OS or you won’t get the right binaries

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Cannot read property 'once' of undefined" when using trying ...
node. js - "Cannot read property 'once' of undefined" when using trying to use gridfs for mongodb - Stack Overflow. Stack Overflow for...
Read more >
Cannot read property 'once' of undefined at EventEmitter.ee ...
My request completes with the correct respsonse but an error come with it. Uncaught TypeError: Cannot read property 'once' of undefined at ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError : Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an...
Read more >
TypeError: Cannot read properties of undefined ... - MongoDB
I have this code here: import { MongoClient } from "mongodb"; const createConnection = () => { // let current = null; const...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found