SAP / cloud-sdk-js

Use the SAP Cloud SDK for JavaScript / TypeScript to reduce development effort when building applications on SAP Business Technology Platform that communicate with SAP solutions and services such as SAP S/4HANA Cloud, SAP SuccessFactors, and many others.
Apache License 2.0
161 stars 53 forks source link

Question: Deployment to SAP CF does not work: ERR Error: Cannot find module '@sap-cloud-sdk/http-client' #4744

Closed sfdfklskldf closed 1 month ago

sfdfklskldf commented 1 month ago

If I run a SAP CAP app locally with "cds watch" there is no issue with the package "@sap-cloud-sdk/http-client" if I try to deploy it as mta build I get ''ERR Error: Cannot find module @sap-cloud-sdk/http-client''

It is mentioned in package.json like this

"dependencies": {
    "@sap-cloud-sdk/connectivity": "^3.15.0",
    "@sap-cloud-sdk/http-client": "^3.15.0",
    "@sap/cds": "^7.9.2",
    "@sap/cds-hana": "^2.0.0",
    "@sap/xssec": "^4.0.2",

It is used in a .js-file that is placed under a "lib" folder like this:

const client = require('@sap-cloud-sdk/http-client');

Compare: https://developers.sap.com/tutorials/cap-soap-service..html Step 8)

What could be the issue that the package could not be found on CF? I am sure it must be a small problem but I can't find it :-/

deekshas8 commented 1 month ago

Hi @sfdfklskldf ,

This looks correct to me. Our docs regarding this issue also mention the same solution. If it's an issue during deployment, it might be related to your mta config. I would suggest to reach out to CAP.

sfdfklskldf commented 1 month ago

But how could MTA-build introduce an issue here? Could it be that the error is triggered because of some packange configuration is missing? I am not yet sure if my code itself would work already correct. But the error says it could not find the complete module. I already tested to avoid sending node_modules inside the MTA package to force installation in the cloud but does not work:

modules:
  - name: myapp-srv
    type: nodejs
    path: gen/srv
    parameters:
      buildpack: nodejs_buildpack
    build-parameters:
      builder: npm
      ignore: ["node_modules/"]