node-html-to-text
node-html-to-text copied to clipboard
Cannot resolve module 'fs'
HI
I npm html-to-text and import ,but there is an error Cannot resolve module 'fs' in xxxxxx/node_modules/.3.1.0@html-to-text/lib, please help fix it
many thanks
Do you run html-to-text in the browser?
Same problem here. I'm using node and just trying to use html-to-text
with import htmlToText from 'html-to-text'
. Here is the trace:
ERROR in ./~/html-to-text/lib/html-to-text.js
Module not found: Error: Can't resolve 'fs' in '/home/lize/Informatique/pellov/node_modules/html-to-text/lib'
@ ./~/html-to-text/lib/html-to-text.js 1:9-22
@ ./~/html-to-text/index.js
…
@liZe again do you try to run html-to-text in the browser?
html-to-text does currently only work in server environments.
again do you try to run html-to-text in the browser?
I do, sorry.
Depending on the build tool you need to provide a mock implementation or for example in webpack you need to set node: { fs: 'empty' }
in your webpack config. Maybe this Stack Overflow Issue can help further: http://stackoverflow.com/questions/39249237/node-cannot-find-module-fs-when-using-webpack
Thanks a lot for the hints, it'll do the job for me!
Our fork @ https://github.com/calcbench/node-html-to-text seems to run in the client with webpack/babel.
Time to close this.
CLI is moved to external package in version 9, so there are no node
dependencies left in html-to-text
.
And even before now, people were using the package with web bundlers for quite a while.
An issue with webpack 4 is hopefully resolved in version 9.