typescriptsapui5ui5-tooling

Use NPM Packages with SAPUI5 Typescript


I am trying to use the npm-package soap in my SAPUI5 APP.

I am new to web development, so I tried to follow this tutorial:
https://github.com/SAP-samples/ui5-typescript-tutorial/tree/main/exercises/ex8

What I have tried:

But I get errors like this in chrome console:

GET http://</resources/http.js net::ERR_ABORTED 404 (Not Found) loadScript @ ui5loader.js:1351 2022-05-24 10:39:01.476100 failed to load JavaScript resource: http.js - sap.ui.ModuleSystem Log.js?eval:452

In the terminal I get messages like:

preferring built-in module http over local alternative at /home/user/projects/zvtle.om/node_modules/string_decoder/lib/http.js, pass preferBuiltins: false to disable this behavior or preferBuiltins: true to disable this warning

In Chrome under sources then resources I can see that the UI5 libraries are loaded, and a soap.js file that has been parsed and now uses sap.ui.definde. However, all of the packages that soap would require (such as http) are not loaded.

I have searched a long time and did not find where I could parse preferBuiltins: true as mentioned in the terminal output and I am not even sure if that would fix my problems.


Solution

  • the npm package soap is for Node.js and does not work in a browser. The http package is a standard Node.js package.

    I think the package easy-soap-request (https://www.npmjs.com/package/easy-soap-request) might fit your need. I have no experience with this package though, but the readme provides an example from the browser.