cancel
Showing results for 
Search instead for 
Did you mean: 

CDS 6 BTP CF deployment - @sap/cds or @sap/cds-dk?

mattredfig
Participant
6,732

Hey all - with the new CDS 6 release, I am attempting to upgrade my project environment to Node 16 as recommended. I have everything working fine locally but when deploying to cloud foundry I ran into this error when running "npx cds run" to :

npm ERR! could not determine executable to run

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/matthewreddy/.npm/_logs/2022-07-09T05_14_51_704Z-debug-0.log<br>

I have narrowed down the difference to the presence of @sap/cds-dk v6.0.2 (devDependency) and @sap/cds v6.0.2 (regular dependency) by removing all node modules, fixing my local node to the exact release of Node that the CF nodejs buildpack runs (16.14.2) running a "--production" installation locally (as is done during remote deploy).

Previously, in cds 5.x.x and Node 12 this paradigm worked fine. "npx cds ..." would be recognized as a command supplied by @sap/cds. However, with cds 6.x.x it seems to require @sap/cds-dk to recognize the command.

My question - is this an intentional change? And if so, it seems like we would need both @sap/cds and @sap/cds-dk based on the docs: @sap/cds-dk for the CLI commands and @sap/cds for project usage (i.e. "let cds = require('@sap/cds-dk')". My original impression - from back in the CDS 3 days - was that @sap/cds-dk was meant for local development while the leaner, more direct @sap/cds was intended for production (remote) deployment.

View Entire Topic
LNR
Discoverer

For me it was related to a missing system link, my ./node_modules/bin did not contain a "cds" entry after doing "npm clean-install --production" (or --omit=dev), unless cds-dk was also included as a dependency, even thou sap/cds clearly has a "bin" property in it's package.json.

My workaround was to modify my script to call "npm rebuild" afterwards, then I don't have to include cds-dk into a dependency. Hope it helps someone else.

muellinho
Explorer
0 Kudos

Hi,

that's exactly what happened to me as well.

However, as I'm deploying with a release pipeline and the cf cli with multiapps plugin, I'd need to ssh into the deployed container after deployment to run npm rebuild.

Have you by any chance figured out by now what the root cause was / is?

Thank you very much (I was close to pulling my hair out of my head :D)

Best regards

muellinho
Explorer

I found additional clues regarding the issue.

Did you maybe use cds-swagger-ui-express as a dev dependency?

In case you did, this issue on github has some more detail to the issue and how it can be solved without adding either cds-dk as a dependency or executing npm rebuild.

Cheers

frankmeertens
Explorer
0 Kudos

Thanks for sharing the updates, Jan.

mattredfig
Participant

I've accepted this as the answer. My new start script is:

"start": "npm rebuild && npx cds run",

I still think this should only be considered a workaround - looking for a more permanent solution, but to be honest the symlink/bin/etc stuff is always a little over my head so I'm not sure what the right outcome is.

swati_maste
Product and Topic Expert
Product and Topic Expert
0 Kudos

I faced the same issue last week, changing the start script to "start": "npm rebuild && npx cds run", solved the issue for me. Thank you 🙂

gregorw
SAP Mentor
SAP Mentor

Please check the release notes:

https://cap.cloud.sap/docs/releases/jun23#use-cds-serve-as-start-script

and use cds-serve for productive start.