0
votes

I'm trying to install the aws amplify cli on my Mac. It seems to install ok, but when i run it afterwards is responds with

     bash: amplify: command not found

I was thinking that it probably had something to do with the directory of the global npm packages, so i ran

    $ npm -g root

Which returned:

    /usr/local/lib/node_modules/node/lib/node_modules

It seems very odd that my node_modules are placed inside another node modules folder.

When i run:

    $ which npm

it returns:

    /usr/local/bin/npm

I also tried listing my global packages with the command

    $ npm list -g --depth=0

Which returned:

/usr/local/lib/node_modules/node/lib
├── @angular/[email protected]
├── @aws-amplify/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Can somebody please help me sort this mess out?

2
is it only problem with amplify cli for you? or any other global modules are affected as well?iurii

2 Answers

1
votes

I ran into the same issue following the AWS Tutorial for deploying a React App: https://aws.amazon.com/getting-started/hands-on/build-react-app-amplify-graphql/module-two/

I used the command below as stated in the tutorial to install the Amplify CLI:

npm install -g @aws-amplify/cli 

The packages installed successfully but after moving to the next step of the tutorial I got the same error:

amplify: command not found

The issue was the package was being installed outside my path and could not be found. However running the curl command below added the necessary line to my zshrc file and configured my $Path correctly.

curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL

(https://docs.amplify.aws/cli/start/install)

This is the result of running the curl command above

The line below was automatically added to my .zshrc file:

# Added by Amplify CLI binary installer
export PATH="$HOME/.amplify/bin:$PATH"
1
votes

In case if someone is installing amplify using curl on Mac, then you need to edit your .zprofile (if you are using zsh terminal) or .bash_profile. Open your terminal

1. cd
2. vim .zprofile
3. Press i, then paste this line
export PATH="$HOME/.amplify/bin:$PATH" 
4. Press Esc and :wq to save this file
5. Restart your terminal