Module not found: Error: Can't resolve 'http'
Hi, thanks for your great job !
i don't manage to use your library
I'm doing a node/angular/ionic 4 app with last version npm packages
i try u node.js example and i got :
[ng] ERROR in ./node_modules/rss-parser/lib/parser.js
[ng] Module not found: Error: Can't resolve 'http' in 'C:\Users\MyAccount\source\repos\just-s-app\node_modules\rss-parser\lib'
[ng] ERROR in ./node_modules/rss-parser/lib/parser.js
[ng] Module not found: Error: Can't resolve 'https' in 'C:\Users\MyAccount\source\repos\just-s-app\node_modules\rss-parser\lib'
[ng] i 「wdm」: Failed to compile.
i try modify the tsconfig.json
i try you web example :
file at « http://localhost:8100/node_modules/rss-parser/dist/rss-parser.min.js » was block because of incorrect type MIME (« text/html ») (X-Content-Type-Options: nosniff).
i try this method : https://www.techiediaries.com/rss-atom-reader-ionic-3/
all that without any result :s sorry i'm noob to Node.JS, and sorry for my english i'm french
thanks !
Are you running this using node, or in the browser?
Ionic runs in the browser. This issue is related to https://github.com/bobby-brennan/rss-parser/issues/98 My example has exactly this problem. See this example: https://github.com/tofra/angular-rss-parser
(let's continue in this thread, or in my repo)
i'm runnign my test in firefox
How are you serving http://localhost:8100/node_modules/rss-parser/dist/rss-parser.min.js? The mimetype should be set as application/javascript, not text/html
In Angular (and Ionic) rss-parser (and other packages in vendor) being compiled to vendor.js which is served as Content-Type: application/javascript; charset=UTF-8
That doesn't seem to be the case in Guill4um's example, given this error message:
file at « http://localhost:8100/node_modules/rss-parser/dist/rss-parser.min.js » was block because of incorrect type MIME (« text/html ») (X-Content-Type-Options: nosniff).
It's certainly not best practice, but you can always add rss-parser.min.js to your index.html and declare let RSSParser any
You're right. I had missed that. It doesn't work like that because Ionic isn't serving the node_modules directory.
I found a solution for Angular/Ionic! Add this to package.json
"browser": {
"http": false,
"https": false
}
Run npm install stream timers --save
Thanks for the update tofra! Does parseURL still work without http and https? Or do you need to use parseString?
hi, using tofra solution, it compiles well. but indeed, using parseURL i got this message >_<
ERROR Error: "Uncaught (in promise): TypeError: get is not a function
parseURL/prom<@http://localhost:8100/vendor.js:89159:17
i have allready tried the mime type wihout success. but now i'll try with the CorsE exstention (Cross-origin resource sharing) https://en.wikipedia.org/wiki/Cross-origin_resource_sharing https://addons.mozilla.org/fr/firefox/addon/cors-everywhere/
Cors prevent the js file to be downloaded :)
with your web example i always got :
File « http://localhost:8100/node_modules/rss-parser/dist/rss-parser.min.js »
was blocked because of type MIME (« text/html ») incorrect (X-Content-Type-Options: nosniff)
using this html :
<script type="application/javascript" src="/node_modules/rss-parser/dist/rss-parser.min.js"></script>
it seems to work pasting the "rss-parser.min.js" content directly in a script block in my index.html file
it's really not a good practice ... i don't know why this mime type is not good : S
Tofra your example is working ? here : https://github.com/tofra/angular-rss-parser ?
No, I haven't fixed it there. If you add this https://github.com/bobby-brennan/rss-parser/issues/109#issuecomment-488140522 then it will work. So this issue can be closed (as it has basically nothing to do with the bundle, just with using this with Angular/Ionic
it doesn't work for me :
Add this to package.json
"browser": { "http": false, "https": false }
Run npm install stream timers --save
:/
i can't use parseURL .
But that was not the issue of this ticket :-) With these additions you did came some steps further.
Do you have a repo where we can check the code? I'll try parseURL tomorrow or in the weekend.
+1, seeing this issue as well in react/TS + yarn project. I am getting cannot resolve errors for http, https, and buffer. The above solution didn't work for me. Any pointers or updates?
It seems that on webpack you must add it to webpack configuration:
your_webpack_configuration = {
...,
resolve: {
fallback: {
http: false,
https: false
}
}
}