为什么在使用 Yarn 全局安装时 nx serve 不起作用?

问题描述

我使用 npx 启动了一个 Nx 工作区:

npx create-nx-workspace

我在 nx 完成引导我的工作区后得到这个:

 This means that you might have to use "yarn nx" or "npx nx" to execute command
s in the workspace.
  Run "yarn global add nx" or "npm install -g nx" to be able to execute command
directly.

我想直接执行命令并想使用纱线所以:

yarn global add nx

并获得成功消息:

yarn global v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "nx@12.5.8" with binaries:
      - nx
Done in 9.40s.

我进入我的工作区,并尝试使用我之前安装的 nx cli 为我的“todos”应用程序提供服务:

cd myorg
nx serve todos

但我收到此错误

bash: nx: command not found

我重新启动了我的终端并再次尝试 serve 但得到了同样的错误serve 在我执行 yarn nx serve todos 时有效,但是,我很想了解为什么以及如何使直接命令与 Yarn 一起工作。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)