微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决为什么在使用 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 举报,一经查实,本站将立刻删除。