TypeError: Cannot read properties of undefined (reading 'type')
See original GitHub issueHello, I am trying to use html2docx for a react project. But for some reason it keeps crashing with the error: TypeError: Cannot read properties of undefined (reading ‘type’)
I have tried it with the example and then changed it. Both codes yield the same error.
var html = `<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>` +
data +
`
</body>
</html>`;
HTMLtoDOCX(data, null, {
table: { row: { cantSplit: true } },
footer: true,
pageNumber: true,
})
.then((fileBuffer) => {
fs.writeFile("./document.docx", fileBuffer, (error) => {
if (error) {
console.log("Docx file creation failed");
return;
}
console.log("Docx file created successfully");
});
})
.catch((err) => {
alert(err);
});
This is my rendition of the code.
My enviroment:
macOS: 12.0 Beta package version: 1.2.4 node version: v16.3.0
Thank you
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Cannot Read Property of Undefined in JavaScript - Rollbar
The TypeError: Cannot read property of undefined is one of the most common type errors in JavaScript. It occurs when a property is...
Read more >Uncaught TypeError: Cannot read property of undefined In
JavaScript TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or...
Read more >TypeError: Cannot read properties of undefined (reading 'and')
It keeps failing with this error in Karma. TypeError: Cannot read properties of undefined (reading 'and') import { ComponentFixture, TestBed } ...
Read more >[Solved] Cannot read Properties of Undefined in JavaScript
The "Cannot read properties of undefined" error occurs when you try to access a property or a method on a variable that stores...
Read more >Uncaught TypeError : Cannot read properties of undefined
The solution to TypeError: Cannot read properties of undefined ... The root cause of the error is that the declared variable doesn't have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zees98 No worries, Its quite unlikely that the package failed with that html string because I am able to generate it without any issue on my laptop with react-example in the
examples/
in this repo.Could you please let me know what’s the end result after clone this repository, and run the example and try it out? I am super curious about this issue.
html-to-docx.docx
@zees98 I might possibly have figured out the issue, please follow the step in the other issue.