Uncaught ModuleError: Failed to resolve dependencies of 'sap/ui/core/Core.js'
stna1981 opened this issue · 10 comments
Hello,
I'm using Visual Studio Code under Windows 11 together with WSL2 and Ubuntu 22.04. I do everything like git etc. from the console within VSC, but for running OPA Tests locally, I want to use my Windows Chrome browser. As I failed repeatedly, I tried it with the official demo project: https://github.com/SAP/openui5-sample-app.git
After "npm install", I can do a "ui5 serve -o index.html" without any problems from the Windows browser. I can also open the file "testsuite.qunit.html" from the folder "webapp/test" and all tests run perfectly fine. However, if I want to run the tests directly from the console via e. g. npm run watch
then this does not work. I added the line "process.env.CHROME_BIN = '/mnt/c/Program Files/Google/Chrome/Application/chrome.exe'" at top of the file karma.conf.js to delegate the call to the Windows browser. The browser open, but then the console shows the following:
[info] graph:helpers:ui5Framework: Using OpenUI5 version: 1.113.0
08 05 2023 16:18:02.147:INFO [karma-server]: Karma v6.4.2 server started at http://localhost:9876/
08 05 2023 16:18:02.153:INFO [launcher]: Launching browsers CustomChrome with concurrency unlimited
08 05 2023 16:18:02.164:INFO [launcher]: Starting browser Chrome
08 05 2023 16:18:05.844:INFO [Chrome 112.0.0.0 (Windows 10)]: Connected on socket ATF6Fl_RLuoiFY4UAAAB with id 75895222
Chrome 112.0.0.0 (Windows 10) ERROR
Uncaught ModuleError: Failed to resolve dependencies of 'sap/ui/core/Core.js'
-> 'sap/uiManagedObject.js'
-> 'sap/uiManagedObjectMetadata.js'
-> 'sap/ui/core/Lib.js'
-> 'sapi18n/ResourceBundle.js'
-> 'sapstrings/formatMessage.js': failed to load 'sapstrings/formatMessage.js' from ../../resources/sapstrings/formatMessage.js: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'webapp/resources/sap/base/strings/formatMessage.js'.
at webapp/resources/ui5loader.js:1692:5
I have no clue what the reason for this could be. Can anyone give a hint? It would be really helpful if I would be able to get the OPAs running locally.
Best regards
Stefan
Not sure whether this really stems from the original problem, but what immediately jumps to my eyes is that several module names are missing a "/base" in their name.
Well that makes sense. But I did not touch anything which could lead to that issue. And the same sources (project) works fine when I try it directly from Windows itself with git and NodeJS for Windows. So the root cause seems to be somehow related to the use inside the WSL. But I have no idea why or where the "/base" part of the paths gets lost...
Could you please provide the full output when using the karma config 'logLevel' set to DEBUG ?
Attached the output. While generating the log file, it worked once without any problem, the tests ran through. But the next time, I received the known errors again. So it's really likely a problem of the handling inside WSL. Chrome - which runs on Windows - can't access the files provided from inside the WSL. But it's strange that it works sometimes. Maybe some kind of race condition?
Any update?
According to the author it has been resolved. @stna1981 please let us know in case you still face issues.
Too bad the issue was closed. I'm using karma-ui5@4.0.1 and the error is still there. I suspect that the error occurs when the sap-ui-core is loaded too quickly. In my case, I set the log level to 1 and always got the error.
Are you manipulating the URL somewhere and cutting out "base"?
My workaround is to increase the log level to 3 as shown here.
@r1mar could you please create a new issue with all the relevant details of your environment incl. a minimal reproducible example (e.g. GitHub repo or zip file)? Without that it will be very hard for us to reproduce the issue.
@matz3 I tried to create a minimal example. Unfortunately, I was not able to reproduce the error outside of our repository. I understand that you cannot reproduce it without such an example. On the other hand, I cannot provide you with proprietary source code. Instead, I will open a support ticket with SAP. I could very well make our repository available there.
SAP limited the problem for me. In my project, I imported and used the NPM module fetch-mock with the help of ui5-tooling-modules.
When I removed the modules, everything was fine again.