Skip to Content
Technical Articles

CDS cli npm install Error @sap/cds-dk Windows (ELIFECYCLE)

If you try to install the new NPM Package for CDS command line tools – @sap/cds-dk (CAP https://cap.cloud.sap/docs/about/#tools-support) on your local Windows machine you may get this error “npm ERR! code ELIFECYCLE” and installation fails.

npm install -global @sap/cds-dk

 

Luckily SAP provide a hint:

The command 'cds' has moved from library @sap/cds to @sap/cds-dk.
It is recommended to remove the global version of @sap/cds and
reinstall @sap/cds-dk via
    npm rm -g @sap/cds
    npm i -g @sap/cds-dk

 

So you do as you’re told:

npm rm -g @sap/cds

npm i -g @sap/cds-dk

 

and… Damn!

 

Solution

Find your installation directory of the global npm packages (usually C:\Users\<User Name>\AppData\Roaming\npm\node_modules)

npm root -g

 

rd C:\Users\<User Name>\AppData\Roaming\npm\node_modules\@sap\cds /S

 

And finally

npm install -global @sap/cds-dk

 

CAP Tutorial: https://developers.sap.com/tutorials/cp-apm-nodejs-create-service.html

CAP CodeJam Material: https://github.com/SAP-samples/cloud-cap-nodejs-codejam

 

1 Comment
You must be Logged on to comment or reply to a post.
  • I got the following problem with the WebIDE generated SAP Business Application template:

    The build process would always fail at the database module build as follows

    10:55:03 PM (Executor) > RTH@1.0.0 build /projects/RTH
    10:55:03 PM (Executor) > cds build
    10:55:03 PM (Executor) 
    10:55:03 PM (Executor) 
    10:55:03 PM (Executor)     'cds build' needs '@sap/cds-dk' to be installed. Get it with:
    10:55:03 PM (Executor) 
    10:55:03 PM (Executor)       npm i -g @sap/cds-dk
    10:55:03 PM (Executor) 
    10:55:03 PM (Executor) npm ERR! code ELIFECYCLE
    10:55:03 PM (Executor) npm ERR! errno 1
    10:55:03 PM (Executor) npm ERR! RTH@1.0.0 build: `cds build`
    10:55:03 PM (Executor) npm ERR! Exit status 1
    10:55:03 PM (Executor) npm ERR! 
    10:55:03 PM (Executor) npm ERR! Failed at the RTH@1.0.0 build script.
    10:55:03 PM (Executor) npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    10:55:03 PM (Executor) 
    10:55:03 PM (Executor) npm ERR! A complete log of this run can be found in:
    10:55:03 PM (Executor) npm ERR!     /home/user/.npm/_logs/2020-08-17T21_55_03_429Z-debug.log
    10:55:03 PM (Executor) child_process.js:669
    10:55:03 PM (Executor)     throw err;
    10:55:03 PM (Executor)     ^
    10:55:03 PM (Executor) 
    10:55:03 PM (Executor) Error: Command failed: npm install && npm run build
    10:55:03 PM (Executor)     at checkExecSyncError (child_process.js:629:11)
    10:55:03 PM (Executor)     at Object.execSync (child_process.js:666:13)
    10:55:03 PM (Executor)     at Object.<anonymous> (/projects/RTH/db/.build.js:12:15)
    10:55:03 PM (Executor)     at Module._compile (internal/modules/cjs/loader.js:778:30)
    10:55:03 PM (Executor)     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    10:55:03 PM (Executor)     at Module.load (internal/modules/cjs/loader.js:653:32)
    10:55:03 PM (Executor)     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    10:55:03 PM (Executor)     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    10:55:03 PM (Executor)     at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    10:55:03 PM (Executor)     at startup (internal/bootstrap/node.js:283:19)
    10:55:03 PM (Executor) npm ERR! code ELIFECYCLE
    10:55:03 PM (Executor) npm ERR! errno 1
    10:55:03 PM (Executor) npm ERR! deploy@ postinstall: `node .build.js`
    10:55:03 PM (Executor) npm ERR! Exit status 1
    10:55:03 PM (Executor) npm ERR! 
    10:55:03 PM (Executor) npm ERR! Failed at the deploy@ postinstall script.
    10:55:03 PM (Executor) npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    10:55:03 PM (Executor) 
    10:55:03 PM (Executor) npm ERR! A complete log of this run can be found in:
    10:55:03 PM (Executor) npm ERR!     /home/user/.npm/_logs/2020-08-17T21_55_03_448Z-debug.log
    10:55:03 PM (Executor) [2020-08-17 21:55:03] ERROR could not build the "RTH-db" module: could not execute the "npm install --production" command: exit status 1
    10:55:03 PM (Executor) make: *** [Makefile_20200817215450.mta:37: RTH-db] Error 1
    10:55:03 PM (Executor) Error: could not build the MTA project: could not execute the "make -f Makefile_20200817215450.mta p=cf mtar= strict=true mode=" command: exit status 2
    10:55:03 PM (MTA BUILD) The "Task for mta build" process finished with code 1
    10:55:03 PM (MTA BUILD) Build of "RTH" failed.

    and I managed to fix it by forcibly adding the

    npm install -global @sap/cds-dk

    into the .build.js of the db module of the RTH application

    // Executes the CDS build depending on whether we have a top-level package.json.
    // Package.json is not available when we are called by CF/XSA buildpack.  In this case we don't do anything
    // and just assume our model was already built and is available as part of this DB app.
    //
    // This is a workaround that will be replaced by a solution where CDS generates the DB module along with package.json.
    
    const fs = require('fs');
    const childproc = require('child_process');
    
    if (fs.existsSync('../package.json')) {
        // true at build-time, false at CF staging time
        childproc.execSync('npm install -global @sap/cds-dk && npm install && npm run build', {
            cwd: '..',
            stdio: 'inherit'
        });
    }