Giter VIP home page Giter VIP logo

Comments (16)

meta-akshita-agrawal avatar meta-akshita-agrawal commented on July 18, 2024 1

Thanks for the update

from html-to-docx.

tco7878 avatar tco7878 commented on July 18, 2024 1

@privateOmega I've just tested it and import htmlToDocx from 'html-to-docx' leads to the same error. I've also tested import {htmlToDocx} from 'html-to-docx' and const htmlToDocx = require('html-to-docx') as well as const htmlToDocx = require('html-to-docx/dist/html-to-docx.esm') and const htmlToDocx = require('html-to-docx/dist/html-to-docx.umd') all of them throwing the previously mentioned error.

from html-to-docx.

tco7878 avatar tco7878 commented on July 18, 2024 1

Update: I've found out that this issue only occurs when targeting ES5. When targeting ES2015 in Angular html-to-docx works like a charm. Unfortunately targeting es2015 is not an option for us. I'll try to further investigate this issue

from html-to-docx.

privateOmega avatar privateOmega commented on July 18, 2024

@meta-akshita-agrawal Could you please post some details about what you have tried so far? A snippet of code or description would do.

from html-to-docx.

meta-akshita-agrawal avatar meta-akshita-agrawal commented on July 18, 2024

I tried
import * as htmlToDocx from 'html-to-docx'
import {htmlToDocx} from 'html-to-docx'
const htmlToDocx = require('html-to-docx')
also here is one of your example I tried to import this too. But that didn't work too

from html-to-docx.

privateOmega avatar privateOmega commented on July 18, 2024

@meta-akshita-agrawal What do you mean it didn't work? Any particular errors or it says htmlToDocx is undefined or something? Could you please post the exact log?

from html-to-docx.

meta-akshita-agrawal avatar meta-akshita-agrawal commented on July 18, 2024

While doing npm start

ERROR in ./node_modules/clean-css/lib/reader/read-sources.js Module not found: Error: Can't resolve 'fs' in 'node_modules\clean-css\lib\reader' ERROR in ./node_modules/clean-css/lib/reader/apply-source-maps.js Module not found: Error: Can't resolve 'fs' in 'node_modules\clean-css\lib\reader' ERROR in ./node_modules/clean-css/lib/reader/load-original-sources.js Module not found: Error: Can't resolve 'fs' in 'node_modules\clean-css\lib\reader' ERROR in ./node_modules/html-to-docx/node_modules/image-size/dist/index.js Module not found: Error: Can't resolve 'fs' in 'node_modules\html-to-docx\node_modules\image-size\dist' ERROR in ./node_modules/html-to-docx/node_modules/image-size/dist/fs.promises.js Module not found: Error: Can't resolve 'fs' in node_modules\html-to-docx\node_modules\image-size\dist' ERROR in ./node_modules/html-to-docx/node_modules/image-size/dist/types/tiff.js Module not found: Error: Can't resolve 'fs' in 'node_modules\html-to-docx\node_modules\image-size\dist\types' ERROR in ./node_modules/uglify-js/tools/node.js Module not found: Error: Can't resolve 'fs' in 'node_modules\uglify-js\tools' Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys' Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp' Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys' Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys'

Screenshot 2021-01-18 152643

from html-to-docx.

privateOmega avatar privateOmega commented on July 18, 2024

@meta-akshita-agrawal Yup that error log makes sense, because fs is a node.js module, hence stubbed out in browser environment and I forgot that I use a dependency which internally depends on fs module.

This has been a long running issue that I haven't had much time to focus on, I had created a branch for that. I will try to work on it sometime soon.

In the meanwhile I guess you can install using that branch and it should work, but you might be missing out on some features for the time being, which I can hopefully rebase it to latest version by tonight.

Closing this issue to track it at one place.

from html-to-docx.

joeskeen avatar joeskeen commented on July 18, 2024

@privateOmega any update on when that branch can be rebased on the latest version? I'm guessing it didn't happen "tonight" (16 days ago) ;)

from html-to-docx.

privateOmega avatar privateOmega commented on July 18, 2024

@joeskeen Please checkout the branch now, it was rebased against develop, hence should have the latest features, unfortunately I can't commit any time at present to this feature now due to my other commitments, but it should work for your use case I guess. Feel free to comment below, if you are facing some issues on that.

from html-to-docx.

tco7878 avatar tco7878 commented on July 18, 2024

@privateOmega Thank you for this long awaited feature :)

I am currently trying to get it to work in an Angular Application using the following code:

import * as htmlToDocx from 'html-to-docx/dist/html-to-docx.umd'

[...]

const htmlString = '<b>Test</b>'
const fileBuffer = await htmlToDocx(htmlString, null, {
    table: {row: {cantSplit: true}},
    footer: true,
    pageNumber: true,
});
saveAs(fileBuffer, "document.docx");

However I am getting the following error:

ERROR Error: Uncaught (in promise): TypeError: Cannot call a class as a function
TypeError: Cannot call a class as a function
    at _classCallCheck (classCallCheck.js:3)
    at new NodeImpl (NodeImpl.js:18)
    at DocumentImpl._createSuperInternal (createSuper.js:15)
    at new DocumentImpl (DocumentImpl.js:21)
    at Object.create_document (CreateAlgorithm.js:55)
    at new WindowImpl (WindowImpl.js:19)
    at Function._create (WindowImpl.js:29)
    at Object.create_window (CreateAlgorithm.js:41)
    at DOMImpl.get (DOMImpl.js:53)
    at new DOMImplementationImpl (DOMImplementationImpl.js:18)
    at resolvePromise (zone.js:1255)
    at zone.js:1162
    at rejected (components-gvp-overview-gvp-module.js:66753)
    at ZoneDelegate.invoke (zone.js:400)
    at Object.onInvoke (core.js:28553)
    at ZoneDelegate.invoke (zone.js:399)
    at Zone.run (zone.js:160)
    at zone.js:1318
    at ZoneDelegate.invokeTask (zone.js:434)
    at Object.onInvokeTask (core.js:28540)

Any Ideas on how to resolve that?

from html-to-docx.

privateOmega avatar privateOmega commented on July 18, 2024

@tco7878 Why are you importing and using the umd build?

Can't you just do import * as htmlToDocx from 'html-to-docx' and I guess that should work.

from html-to-docx.

tco7878 avatar tco7878 commented on July 18, 2024

@privateOmega thanks for your answer. Unfortunately this does not help. I did try importing from 'html-to-docx' as well as importing the esm and umd build directly. The error remains the same

My Angular project is targeting ES5 maybe it is related to that.

from html-to-docx.

privateOmega avatar privateOmega commented on July 18, 2024

@tco7878 Sorry I couldn't be of more help, I am not that used to typescript and also just curious, do you get the the same error when you use the import * as htmlToDocx from 'html-to-docx'? and also see if import htmlToDocx from 'html-to-docx' works for you?

from html-to-docx.

ammarmohamed2016 avatar ammarmohamed2016 commented on July 18, 2024

Any update about this issue @tco7878 @privateOmega ?

from html-to-docx.

artemdumanov avatar artemdumanov commented on July 18, 2024

As a workaround, you can use
// @ts-ignore

from html-to-docx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.