html-to-text / node-html-to-text

Advanced html to text converter
Other
1.6k stars 224 forks source link

Can't import the named export 'Picker' from non EcmaScript module #254

Closed iMohamedSamir closed 1 year ago

iMohamedSamir commented 2 years ago

I am keep having this error:

./node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.mjs
Can't import the named export 'Picker' from non EcmaScript module (only default export is available)

when I am using html-to-text to convert some raw html string.

I tried almost every single solution of both these issues: https://github.com/html-to-text/node-html-to-text/issues/229 https://github.com/reactioncommerce/reaction-component-library/issues/399 but nothing worked, expect: https://github.com/reactioncommerce/reaction-component-library/issues/399#issuecomment-467860022 which raised an entirely different error: parseley__WEBPACK_IMPORTED_MODULE_4__.parse1 is not a function

Here are my dependencies, if it helps

  "dependencies": {
    "@apollo/client": "^3.6.2",
    "@reduxjs/toolkit": "^1.8.2",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.2.0",
    "@testing-library/user-event": "^13.5.0",
    "apollo-link-context": "^1.0.20",
    "draft-convert": "^2.1.12",
    "draft-js": "^0.11.7",
    "draftjs-to-html": "^0.9.1",
    "graphql": "^16.4.0",
    "html-to-text": "^8.2.0",
    "install": "^0.13.0",
    "jwt-decode": "^3.1.2",
    "moment": "^2.29.3",
    "npm": "^8.12.2",
    "react": "^17.0.1",
    "react-async": "^10.0.1",
    "react-dom": "^17.0.1",
    "react-draft-wysiwyg": "^1.15.0",
    "react-redux": "^8.0.2",
    "react-router-dom": "^5.3.1",
    "react-scripts": "^2.1.3",
    "semantic-ui-css": "^2.4.1",
    "semantic-ui-react": "^2.1.2",
    "web-vitals": "^2.1.4"
  },

any adives?

KillyMXI commented 2 years ago

See #230

Your links mention config paths specific to certain types of projects. You have to figure out where is the webpack config should be in your project.

iMohamedSamir commented 2 years ago

I was creating webpack.config.js in the root folder, right beside config.json but it had to effect, only when I added the rule manually to node_modules\react-scripts\config\webpack.config.js it worked and I got ride of the error I have another another one: parseley__WEBPACK_IMPORTED_MODULE_4__.parse1 is not a function toAstTerminalPairs projectPath/node_modules/selderee/lib/selderee.mjs:154 this time the error is only in the component which I am using html-to-text in. It's not my first time seeing this error, I had it yesterday when I was trying the previously mentioned solutions. but I though react-app-rewired caused it.

But the error appears even if am not using react-app-rewired.

I think I am ready to give up now, I will try to RegEx the hell out my raw html lol.

KillyMXI commented 2 years ago

I'm sorry for all the trouble. Real life interfere with all my development plans.

You can try the version 7.1.1 - it lacks some features but it should be free of this issue. Perhaps I can release 7.1.2 quickly to resolve audit issues there.

I'll think whether I can break the grand release of v9 into parts to get the feedback on it earlier. (I expect it might solve this issue but I'm not sure.)

P.S. https://stackoverflow.com/a/1732454/3423843

KillyMXI commented 1 year ago

Version 9 is now public. Based on little feedback I've got in #252, webpack issue should be fixed now. Please open a new issue in case there is any problem with version 9.