为什么在我的全局节点模块列表中看不到 Node 和 Yarn?

Why can't I see Node and Yarn in my global node modules list?

我正在阅读 this documentation 如何升级我的 npm 版本,它提到我需要一个特定版本的 Node。我使用 npm ls -g --depth 0(或等效的 ls /usr/local/lib/node_modules)查看了我的全局节点模块列表,并注意到该列表包含 npm,但不包含 Node 或 Yarn。我知道我安装了 Node 和 Yarn,因为 node -vyarn -v 都是 return 版本号,所以我想知道为什么它们不在我的全局模块列表中。

很可能您没有使用 npm 安装 node 或 yarn,它们必须是二进制文件。

使用which 命令找出这些二进制文件的位置。这是它在我的系统上的样子:

which yarn
/usr/local/bin/yarn

which node
/Users/user/.nvm/versions/node/v8.11.2/bin/node