Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: url.parse is not a function #273

Open
futag opened this issue Jun 5, 2024 · 6 comments
Open

TypeError: url.parse is not a function #273

futag opened this issue Jun 5, 2024 · 6 comments

Comments

@futag
Copy link

futag commented Jun 5, 2024

I run rss-parser in svelekit web this happen
image

@Reggionick
Copy link

It seems that you have to install the url package

@yilitai
Copy link

yilitai commented Aug 9, 2024

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.

@qadzek
Copy link

qadzek commented Aug 9, 2024

@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/rss-parser@3.13.0/dist/rss-parser.min.js"></script>
  • Usage inside App.tsx: const parser = new window.RSSParser();

@yilitai
Copy link

yilitai commented Aug 22, 2024

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

@qadzek
Copy link

qadzek commented Aug 22, 2024

@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.

@yilitai
Copy link

yilitai commented Aug 23, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants