Giter Club home page Giter Club logo

Comments (8)

KillyMXI avatar KillyMXI commented on September 19, 2024

Man. There is one thing I hate more than webpack. It is the whole React infrastructure. They ruin JavaScript for everyone else.

Package html-to-text has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in /<project path>/node_modules/html-to-text/package.json

What?

* /<project path>/node_modules/html-to-text/lib/html-to-text.cjs(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

It doesn't recognize cjs as a valid extension and doesn't check "extensionless" file either.
Especially confusing since from the previous warning we can conclude it knows about exports so it can't be that old.
If there is a way to configure it in your project to recognize additional file extension - that should solve this.
Alternatively, you can try html-to-text 8.2.1 - before it switched to dual mode.

Overall, this seems to be an issue of React Native specifically or React pipeline as a whole.
I'm not qualified to help with it.
If you can debug the issue and explain what is missing - I can include the changes unless they cause inconveniences elsewhere.

from node-html-to-text.

KillyMXI avatar KillyMXI commented on September 19, 2024

Relevant issues:
thysultan/stylis#233
emotion-js/emotion#1986
https://www.reddit.com/r/expo/comments/w14tjo/unable_to_resolve_module_cjs/

Looks like there is a way to provide additional file extensions.

If metro bundler is used, then it should be resolved in version 0.72.0:
facebook/metro#535

from node-html-to-text.

tom-dudman avatar tom-dudman commented on September 19, 2024

Thanks @KillyMXI ,

Using 8.2.1 did clear that error, but gave me a new, similar looking one:

Error: While trying to resolve module `@selderee/plugin-htmlparser2` from file `/<project path>/node_modules/html-to-text/lib/html-to-text.js`, the package `/<project path>/node_modules/html-to-text/node_modules/@selderee/plugin-htmlparser2/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/<project path>/node_modules/html-to-text/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.cjs`. Indeed, none of these files exist:

  * /<project path>/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.cjs(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  * /<project path>/node_modules/html-to-text/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.cjs/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)

They absolutely do exist. I've tried all versions of @selderee/plugin-htmlparser2 in html-to-text's package.json but it didn't help.

The project I'm working on is quite old, and managing the dependencies is proving difficult, so I'll look at a cruder solution as the incoming HTML is fairly static.

Thank you very much for your time.

from node-html-to-text.

KillyMXI avatar KillyMXI commented on September 19, 2024

Ah right, I forgot the bundler will have to deal with all my upstream packages as well.

If you can't update the bundler itself, another way might be, perhaps, to bundle problematic dependency first by other means and use that.
Not sure if something like https://esm.sh/ can do that for you.

from node-html-to-text.

tom-dudman avatar tom-dudman commented on September 19, 2024

Success! The steps to solve for me were:

  • Use version 8.2.1
  • Add a resolver.sourceExts to metro.config.js which included cjs and mjs in the list of extensions

Thank you very much for your help with this. Its saved me lots of work maintaining two strings in parallel.

from node-html-to-text.

KillyMXI avatar KillyMXI commented on September 19, 2024

I'm curious whether version 9 works with resolver.sourceExts as well, or what kind of error you get otherwise (and what version of metro you're working with).

from node-html-to-text.

tom-dudman avatar tom-dudman commented on September 19, 2024

With 9.0.5 when running npx react-native start, npx react-native run-android or npx react-native run-ios I get the warning:

Package html-to-text has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in /<project path>/node_modules/html-to-text/package.json

The project uses react-native 0.62.2 ... is that the metro version?... I'm not sure.

from node-html-to-text.

KillyMXI avatar KillyMXI commented on September 19, 2024

So it runs, just has this warning?

I found this issue: uuidjs/uuid#444
and this comment: ai/nanoevents#44 (comment)
Looks like I can add "./package.json": "./package.json" to my exports whenever I will be releasing the next version, but it shouldn't affect the functionality in any way other than this warning, so no need to hurry.

If metro is in the dependency tree, then it should be possible to find it in node_modules or in package-lock.json.

from node-html-to-text.

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.