Showing results for 
Search instead for 
Did you mean: 

CAP - cds-ts powershell bug?

Active Contributor


When running a CAP application with typescript support using the cds-ts command from powershell, I'm running into following error:

When running the same command from a regular command line shell the project is started perfectly:

I'm running the latest version of the @sap/cds-dk at the time of writing

  • @sap/cds: 5.7.4
  • @sap/cds-compiler: 2.11.4
  • @sap/cds-dk: 4.7.2
  • @sap/cds-foss: 3.0.0
  • Node.js: v17.3.0
  • cap-ts: 1.0.0

Running on Windows 11, tried using powershell v5.1 (delivered by default) and powershell 7.2.1.

Anyone facing the same issue when running typescript enabled CAP applications from powershell?

Best regards,


EDIT: a temporary workaround, I adapted the cds-ts.ps1 script commenting out lines 5 -> 9 (ts-node-cwd.exe doesn't exist in my case, by disabling these lines the .exe extension is removed):

EDIT2: Alternative script could be (first checking the exe variant on windows, else loading the cmd version => cmd extension added to prevent the script from opening in a seperate window)

#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent

if ($IsWindows) {
  if (Test-Path "$basedir/ts-node-cwd.exe"){
    $script = "$basedir/ts-node-cwd.exe"
  } elseif (Test-Path "$basedir/ts-node-cwd.cmd"){
    $script = "$basedir/ts-node-cwd.cmd"
  } elseif (Test-Path "ts-node-cwd.exe"){
    $script = "ts-node-cwd.exe"
  } else {
    $script = "ts-node-cwd.cmd"
} else {
  if (Test-Path "$basedir/ts-node-cwd"){
    $script = "$basedir/ts-node-cwd"
  } else {
    $script = "ts-node-cwd"

# Support pipeline input
if ($MyInvocation.ExpectingInput) {
  $input | & "$script"  "$basedir/node_modules/@sap/cds-dk/bin/cds-ts.js" $args
} else {
  & "$script"  "$basedir/node_modules/@sap/cds-dk/bin/cds-ts.js" $args
exit $ret
0 Kudos

Hi 8d8214c7f9734f45be69f95cc0d5aeee ,

I'm facing the exact same issue, using a cmd or bash or the SAP BAS works fine.

When commenting out the mentioned lines, a cmd window pops up and closes.

I came across the same issue (posted by Tobias) in another question with a different solution, which seemed to work for me:

[CAP][CDS-TS] Powershell -> The term 'ts-node.exe' is not recognized as a name of a cmdlet,.. | SAP ...

Any update on this without the workaround?

Thanks in advance!

Best regards,


Accepted Solutions (0)

Answers (2)

Answers (2)

Active Participant

Hello CAPpers,

after following the above suggestions,I I've tried to set Powershell as default under settings in Terminal as well, so VSCode opens new Powershell 7 (pwsh) as default terminal.
I stilled faced the issue, as alternate I tried to run it with

npx cds-ts run

It seems working properly including debugging, so I started to use it in package.json and launch.json in VSCode.

Best regards


0 Kudos

For me the script failed because I used the default PowerShell version (5) in Windows 10. Then $IsWindows in the ps1 script doesn't work. Installing PowerShell 6 or higher fixes that problem. See also:

Next you can also use this command to fix the not found ts-node-cmd:

Add-Content $PROFILE "Set-Alias -Name ts-node-cwd.exe -Value ts-node-cwd.cmd"