首页 > 解决方案 > 一般安装和运行 aws-amplify cli 和全局 npm 包的问题

问题描述

我正在尝试在我的 Mac 上安装 aws amplify cli。它似乎可以安装,但是当我之后运行它时,它会响应

     bash: amplify: command not found

我在想它可能与全局 npm 包的目录有关,所以我跑了

    $ npm -g root

哪个返回:

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

我的 node_modules 放在另一个节点模块文件夹中似乎很奇怪。

当我运行时:

    $ which npm

它返回:

    /usr/local/bin/npm

我还尝试使用命令列出我的全局包

    $ npm list -g --depth=0

哪个返回:

/usr/local/lib/node_modules/node/lib
├── @angular/cli@7.3.1
├── @aws-amplify/cli@1.5.1
├── ng@0.0.0
├── npm@6.9.0
├── npm-check@5.9.0
├── tsc@1.20150623.0
├── typeorm@0.2.16
└── typescript@3.2.2

有人可以帮我解决这个问题吗?

标签: npmaws-amplify

解决方案


如果有人在 Mac 上使用curl安装 amplify ,那么您需要编辑您的 .zprofile(如果您使用的是 zsh 终端)或 .bash_profile。打开你的终端

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

推荐阅读