I am trying to install the aws-cdk and in the terminal and I run the npm install -g aws-cdk. As stated here After npm runs, I get:

/usr/local/Cellar/node/9.8.0/bin/cdk -> /usr/local/Cellar/node/9.8.0/lib/node_modules/aws-cdk/bin/cdk + [email protected] updated 1 package in 1.636s 

If I try to run cdk I get:

zsh: command not found: cdk 
2

5 Answers

Installing as root worked for me: sudo npm install -g aws-cdk

1

Make sure /usr/local/Cellar/node/9.8.0/bin is in your PATH

0

In my case, I added this to the end of my .bash_profile: export PATH=$PATH:$(npm get prefix)/bin. I did that based on information from a different thread.

1

If you're using nvm to manage your node versions, make sure that the CDK package is being installed in the same version of node you're currently using or the version you want to use.

The OP noted their CDK was getting installed in node/9.8.0:

  1. Check the current node version running: nvm current.

  2. If you see that the CDK installation location is different than the node version indicated by nvm current, you'll need to switch your node version using: nvm use <node-version-where-cdk-is-installed>

In the OP's case, this would be nvm use 9.8.0.

What worked for me in mac was adding to the path the bin directory of globally installed node modules.

  1. Install aws-cdk by: npm install -g aws-cdk
  2. Try to run it cdk
  3. no command found error
  4. make or edit your .zshrc file in your user directory
  5. add line to .zshrc with export PATH=$PATH:/{your_user_path}/.npm-global/bin
  6. execute it source .zshrc
  7. now cdk should work

Pay attention that it is mac based approach.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.