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 25 Answers
Installing as root worked for me: sudo npm install -g aws-cdk
Make sure /usr/local/Cellar/node/9.8.0/bin is in your PATH
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.
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:
Check the current node version running:
nvm current.If you see that the
CDKinstallation location is different than thenodeversion indicated bynvm current, you'll need to switch yournodeversion 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.
- Install aws-cdk by:
npm install -g aws-cdk - Try to run it
cdk - no command found error
- make or edit your .zshrc file in your user directory
- add line to .zshrc with
export PATH=$PATH:/{your_user_path}/.npm-global/bin - execute it
source .zshrc - now
cdkshould work
Pay attention that it is mac based approach.