Module not found when I require custom module from my github #1588
Replies: 13 comments
-
Posted at 2021-12-26 by Poolitzer Hi. Just to confirm to you, you do nothing wrong \o/. The issue steams from GitHub not executing a proper CORS response, which in turn stops the browser from executing the request the JS code asks for. There are a couple things you can do to fix this issue: You can install an extension which enters the proper header everywhere (the link there didn't work, see this one . I did get some errors when loading a module that way, and Im not sure if they are expected or a result of the plugin getting in the way, but at least it loads something. There is also the possibility of installing and running the IDE "locally" with NPM. See here. This shouldn't be limited by the missing CORS response as the browser is, I havent been able to try this yet though. In the end, the only way to fix this is the other methods mentioned in the above ReadMe or asking GitHub to implement the proper CORS headers. Maybe they also only have a bug with their http endpoint and it will fix itself at some point? If other people can confirm it used to work, this is a not so unlikely scenario. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-12-26 by Mark_M Thank you Poolitzer. I will try other methods too. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-12-26 by Poolitzer For the second issue, did you do |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-12-26 by Mark_M Yes, I've done everything what was in the manual. I've made it simpler. I run Apache. Configured it for CORS. Copied modules into /var/www/html/mark/BangleApps/modules/
To fix the above issue I've added to my module.
and use it from program following way
Adding to this, it required also to set default expiration to 0 in apache settings. Otherwise Web IDE keeps using old file from browser cache despite it was already modified. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-12-26 by myownself The reason it didn't work without the connect function (the not defined error) is you weren't assigning the result of the require anywhere. You wanted
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-05 by @gfwilliams One issue with your initial code might be that you're entering it on the left-hand side of the IDE? That's a direct connection to the device - if you upload from the right-hand side then the code gets parsed and when external URLs are mentioned they are fetched and uploaded automatically. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-05 by Poolitzer No the CORS issue happens from the right side for me. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-05 by @gfwilliams Odd...
Doesn't work, but:
is fine for me |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-05 by Poolitzer That is because raw.githubusercontent.com does send a proper CORS header, |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-06 by @gfwilliams Did you try it? As I said above, it works. The Web IDE is able to detect github-style URLs and although raw.githubusercontent.com doesn't work, it uses the GitHub API to request the file in a way which DOES work cross origin |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-06 by Poolitzer
Yes, I agree that raw.githubusercontent.com works, while github.com doesn't (just tested again).
Hm. I don't think I can agree with either half of that sentence. If I open raw.githubusercontent.com in my browser and check the request headers, If I check the requests made by the Web IDE, it sends a fetch request to either raw.githubusercontent.com or github.com, depending ofc which you enter in the require call. I don't see a GitHub API request. I can be totally wrong though, never done any JS work. But from the previous two comments from us, I would have made a change to the web IDE just checking if the require is a GitHub.com URL and change it to a raw one, as a hotfix. And then I would have opened an Issue at GitHub asking why they dont pass a cross origin header in GitHub.com and if they have a good reason not to, I guess the hotfix will be a permanent fix. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-06 by Mark_M Thank you guys. Good to know raw.githubusercontent.com can be a workaround. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-07 by @gfwilliams I just looked up the module: https://github.com/espruino/EspruinoTools/blob/master/plugins/getGitHub.js So actually I misremembered - it should be attempting to rewrite github URLs into a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-12-26 by Mark_M
Hi
I am following this doc https://www.espruino.com/Modules#espruino-modules
Created my github https://github.com/markmal/BangleApps/tree/master/modules/
I've put this into web IDE Module URL: https://github.com/markmal/BangleApps/tree/master/modules/|http://www.espruino.com/modules/
Also I tried direct link, but still getting the error
Also tried link that returns plain text
What am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions