Install the AWS CDK CLI

Use the Node Package Manager to install the CDK CLI. We recommend that you install it globally using the following command:

$ npm install -g aws-cdk

To install a specific version of the CDK CLI, use the following command structure:

$ npm install -g aws-cdk@X.YY.Z

If you want to use multiple versions of the AWS CDK, consider installing a matching version of the CDK CLI in individual CDK projects. To do this, remove the -g option from the npm install command. Then, use npx aws-cdk to invoke the CDK CLI. This will run a local version if it exists. Otherwise, the globally installed version will be used.

Troubleshoot a CDK CLI installation

If you get a permission error, and have administrator access on your system, run the following:

$ sudo npm install -g aws-cdk

If you receive an error message, try uninstalling the CDK CLI by running the following:

$ npm uninstall -g aws-cdk

Then, repeat steps to reinstall the CDK CLI.

Verify a successful CDK CLI installation

Run the following command to verify a successful installation. The AWS CDK CLI should output the version number:

$ cdk --version
Updated on