react-nativereact-native-render-html

Unable to resolve XXX from module YYY


I’m building a small app that fetch contents from an API, some of the content is in HTML and i’m willing to display it in HTML (basic tags, like B, I, P and so on). I tried to use react-native-render-html and it also requires react-native-webview (which I also installed) but when starting the expo server with the following include

import { HTML } from 'react-native-render-html';

i got the following error:

Unable to resolve “./MultiplexHandler” from "node_modules\htmlparser2\lib\CollectingHandler.js"

and in fact MultiplexHandler.js is missing from node_modules\htmlparser2\lib\.

At the moment im using:

"react-native-render-html": "^4.2.2-beta.2",
"react-native-webview": "^10.3.2"

Any help would be appreciated, even on alternative way to display a little of HTML text, Thank you


Solution

  • Take #1, metro

    This is probably an issue with metro bundler after you've just added a new dependency. Try restarting with a clean cache:

    npm start -- --reset-cache
    

    Or if you're using expo

    expo start --clear
    

    Also, take notice that working on Windows can cause problems.

    Take #2, dependencies

    The other track would be an issue with yarn or npm. To play it safe, you can do the following in a clean directory (you have committed your changes to whichever CVS you're using):

    1. Delete node_modules.
    2. Delete your lock file, either package-lock.json or yarn.lock.
    3. Perform a fresh install, either npm install or yarn install.