Issues in Jenkins job trying to replace SFDX CLI with the new SF CLI

We have several Jenkins jobs connecting to different SF orgs and working as expected using the old SFDX CLI.

But when we try to update the toolbelt variable that stores the path to the SF commands (everything apart remains the same), we receive the following error message:


TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension “” for D:\Program Files\sf\client\bin\run. Loading extensionless files is not supported inside of “type”:“module” package.json contexts. The package.json file D:\Program Files\sf\client\package.json caused this “type”:“module” context. Try changing D:\Program Files\sf\client\bin\run to have a file extension. Note the “bin” field of package.json can point to a file with an extension, for example {“type”:“module”,“bin”:{“run”:“.\bin\run.js”}}
at new NodeError (node:internal/errors:406:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:99:9)
at defaultGetFormat (node:internal/modules/esm/get_format:142:36)
at defaultLoad (node:internal/modules/esm/load:120:20)
at ModuleLoader.load (node:internal/modules/esm/loader:396:13)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:278:56)
at new ModuleJob (node:internal/modules/esm/module_job:65:26)
at #createModuleJob (node:internal/modules/esm/loader:290:17)
at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:248:34)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:229:17) {

Node.js v20.9.0

The content in the toolbelt variable is the same as the server has in the Path environment variable, and it is working fine from the command line in the server.
That variable stores the following path:
D:\Program Files\sf\bin\sf
But the error message is referring to:
D:\Program Files\sf\client\bin\run
I don´t know why it is working with a different path, and all the content in those folders is generated by the SF CLI installation.

Also, we can use the same code but point to the old SFDX CLI with the following path in the toolbelt variable:
D:\Program Files\sfdx\bin\sfdx

How is that possible and how could we change the code to use the latest sf CLI version instead of the old SFDX CLI.

Thanks in advance,
Javier Carvajal