3

I am looking up the sample for the sap.m.UploadCollection control. I've downloaded and run the sample package locally using the following commands:

npm install

and then

ui5 serve -o index.html

I get the following error in console when navigating to http://localhost:8080/index.html:

2022-08-15 16:56:35.802600 Failed to load component for container container - ModuleError: Failed to resolve dependencies of 'sap/m/sample/UploadCollection/Page.controller.js'
-> 'sap/m/MessageToast.js': failed to load 'sap/m/MessageToast.js' from ./resources/sap/m/MessageToast.js: script load error
ModuleError: Failed to resolve dependencies of 'sap/m/sample/UploadCollection/Page.controller.js'

If I move the Page.contoller.js to a newly created controller folder and move the Page.view.xml to the newly created view folder, then a different error occurs.

How can the downloaded sample project run locally?

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
VilleLipponen
  • 636
  • 1
  • 13
  • 22
  • 1
    Maybe I am missing something but I think they don't provide the framework itself. So to just get it running you could replace `src` in `index.html` with an absolute path (`https://openui5.hana.ondemand.com/resources/sap-ui-core.js`). – Marc Aug 16 '22 at 07:33
  • This is not recommended for prod! – Marc Aug 16 '22 at 14:48
  • Or download the SDK and install it locally?! That's what I do. – Bernard Aug 17 '22 at 05:53
  • @Bernard Usually you would [install local dependencies using ui5.yaml](https://sap.github.io/ui5-tooling/pages/Configuration/#runtime-dependencies) or [create a local proxy which redirects /resources to a CDN](https://www.npmjs.com/package/ui5-middleware-http-proxy). – Marc Aug 17 '22 at 08:21
  • @Marc some people like developing locally without connectivity (some of us are in 3rd world countries :) ). In these situations a local install of the SDK significantly speeds up app performance while doing DEV. (fwiw) – Bernard Aug 17 '22 at 08:42
  • @Bernard Yes, that's why you could install the dependcies with npm/ui5.yaml instead of downloading the SDK. These dependencies will be cached and can be reused in other projects (afaik). – Marc Aug 17 '22 at 09:15
  • Btw. `sap.m.UploadCollection` is **deprecated since UI5 1.88**. Use [`sap.m.upload.UploadSet`](https://sdk.openui5.org/api/sap.m.upload.UploadSet) instead. – Boghyon Hoffmann Aug 22 '22 at 06:04

1 Answers1

0

Make sure that the downloaded project has the UI5 Tooling part is correctly configured according to the documentation https://sap.github.io/ui5-tooling/pages/Configuration

In your case, the control sap.m.UploadCollection is deprecated since UI5 1.88. So download one of the sap.m.upload.UploadSet samples instead. When downloaded, see which settings are missing in the ui5.yaml config file. E.g. run the below UI5 Tooling commands to add the missing settings:

ui5 use openui5@latest
ui5 add sap.ui.core sap.m sap.ui.layout sap.ui.unified themelib_sap_fiori_3 themelib_sap_horizon

This will at least allow the application to start.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170