'How to fix 'command not found' for aws-cdk after running the npm install
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
Solution 1:[1]
Make sure /usr/local/Cellar/node/9.8.0/bin is in your PATH
Solution 2:[2]
Installing as root worked for me:
sudo npm install -g aws-cdk
Solution 3:[3]
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.
Solution 4:[4]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Elad Ben-Israel |
| Solution 2 | yogender |
| Solution 3 | Michael Behrens |
| Solution 4 | LumberManFromOregon |
