privateOmega / html-to-docx

HTML to DOCX converter
MIT License
373 stars 140 forks source link

Can't resolve 'fs' in react.js #212

Open andreeapurta opened 1 year ago

andreeapurta commented 1 year ago

Error: Can't resolve 'fs' in _./nodemodules/html-to-docx/dist/html-to-docx.esm.js:1:164 My code is exactly like this: https://github.com/privateOmega/html-to-docx/blob/master/example/react-example/src/App.js I am using react and next.js And I installed: "html-to-docx": "^1.8.0", "file-saver": "^2.0.5", Can somebody help me please?

PRANJALI-SANKPAL commented 12 months ago

I also faced same problem, I have installed npm again with command "npm install" and my problem got solved.

roberiof commented 11 months ago

The "npm install" didn't solve for me. But putting this in next.config.js worked fine:

module.exports = (phase, { defaultConfig }) => {
  return {
    ...defaultConfig,

    webpack: (config) => {
      config.resolve = {
        ...config.resolve,
        fallback: {
          fs: false,
          path: false,
          os: false
        }
      };
      return config;
    }
  };
};
gauravsapkal1 commented 8 months ago

@roberiof after adding this workaround i am getting "Module not found: Can't resolve 'crypto'" this error in nextjs code is similar to you