rss-parser icon indicating copy to clipboard operation
rss-parser copied to clipboard

TypeError: url.parse is not a function

Open futag opened this issue 1 year ago • 6 comments

I run rss-parser in svelekit web this happen image

futag avatar Jun 05 '24 04:06 futag

It seems that you have to install the url package

Reggionick avatar Jun 12 '24 23:06 Reggionick

I have encountered the exact problem:

Uncaught (in promise) TypeError: url.parse is not a function
    at Parser.parseURL (parser.js:74:24)
    at RSSFeedList.vue:16:12
    at runtime-core.esm-bundler.js:1552:40
    at callWithErrorHandling (runtime-core.esm-bundler.js:202:19)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:209:17)
    at hook.__weh.hook.__weh (runtime-core.esm-bundler.js:1532:19)
    at flushPostFlushCbs (runtime-core.esm-bundler.js:386:32)
    at flushJobs (runtime-core.esm-bundler.js:426:5)

This is a vue+vite+ts project in browser environment (not node.js), the ‘parser.parseURL’ function due to some reason is no longer available in the browser environment. I send this Error to chatgpt which just straight telling me that rss-parser is not for browser environment and I have to look for other packages.

yilitai avatar Aug 09 '24 09:08 yilitai

@uncle-yi I had the same problem, in a React + TS + Vite project for the browser.

To fix this, instead of doing npm i rss-parser, I did the following:

  • Add this to index.html: <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/rss-parser.min.js"></script>
  • Usage inside App.tsx: const parser = new window.RSSParser();

qadzek avatar Aug 09 '24 14:08 qadzek

@qadzek My project really cant use online script but thank you anyway.

yilitai avatar Aug 22 '24 07:08 yilitai

@qadzek My project really cant use online script but thank you anyway.

You can also store the .js file locally and reference its path in the src attribute.

qadzek avatar Aug 22 '24 11:08 qadzek

@qadzek My project really cant use online script but thank you anyway.

You can also store the .js file locally and reference its path in the src attribute.

That sounds like a solution.

yilitai avatar Aug 23 '24 00:08 yilitai