0

I'm trying to use rss-parser in my react app. After installing the library, I implemented the following:

import Parser from 'rss-parser';

let parser = new Parser();

(async () => {

        let feed = await parser.parseURL('https://www.reddit.com/.rss');
        console.log(feed.title);

        feed.items.forEach(item => {
            console.log(item.title + ':' + item.link)
        });

})();

This throws the following error:

ERROR in ./node_modules/rss-parser/lib/parser.js 3:13-28

Module not found: Error: Can't resolve 'http' in '\node_modules\rss-parser\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
    - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "http": false }

Where should I set the resolve.fallback info ?

matdev
  • 4,115
  • 6
  • 35
  • 56
  • why don't you just Add a polyfill for the 'http' module? Sorry, the answer to your question will be in webpack configuration. – Nazrul Chowdhury Jul 21 '23 at 20:10
  • I installed the packages timers-browserify , stream-browserify and url to add polyfill, but I cannot find webpack.config.js file – matdev Jul 22 '23 at 07:46
  • [Here's](https://stackoverflow.com/a/76742015/16298054) an answer that deals with similar issue. Though in your case it will be 'http' module instead of "path". – Nazrul Chowdhury Jul 22 '23 at 08:59

0 Answers0