-
-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: htmlToText is not a function #218
Comments
Pay attention to how the import is done. const { htmlToText } = require('html-to-text'); I should've made it more clear in the changelog. |
Found the problem; I hadn't imported with a specific version so I was using 5.1.1. Already had it in my node_modules and it's required by mailparser 2.7.7. Upgrading html-to-text to 6.0.0 solves the problem. |
Excerpt from README:
|
in my case: it shows like this... how can I solve this problem.. please help !
|
In my app look like this when i add user to with api then i get this error const htmlToText = require('html-to-text');
const mailOptions = {
from: this.from,
to: this.to,
subject,
html,
text: htmlToText.fromString(html)
};
|
I have the same problem... |
@mithunmunsi if your message above from last week is accurate - then it is not the same problem. If you're using If you have an error The only case of reporting the issue then finding the cause is available above. |
const htmlToText = require('html-to-text'); @mithunmunsi Try this: const { convert }= require('html-to-text'); |
Minimal HTML example
using any html
Options
using default options
Observed output
Expected output
Change log says that fromString is deprecated, so trying to use htmlToText. Not sure why htmlToText is not recognized as a function in my code. Tried wrapping it in another function, in an IFFE, nothing works except using the fromString function.
Version information
I'm trying to use htmlToText inside of a curried function (using ramda curryN) and get "TypeError: htmlToText is not a function". It DOES work if instead I use "fromString".
example of failing code:
var objectFromEMail = R.curryN(3, (splitCharsExp, matchCharsExp, payload) => { let rawText = payload.text ? payload.text : payload.html ? htmlToText(payload.html) :
Error - failed to parse email body (no text or html)!...
example of successful code:
var objectFromEMail = R.curryN(3, (splitCharsExp, matchCharsExp, payload) => { let rawText = payload.text ? payload.text : payload.html ? fromString(payload.html) :
Error - failed to parse email body (no text or html)!...
The text was updated successfully, but these errors were encountered: