简体   繁体   English

'nx' 未被识别为 cmdlet 的名称

[英]'nx' is not recognized as the name of a cmdlet

I am trying to add a new util library into my Nx mono repo.我正在尝试将一个新的实用程序库添加到我的 Nx mono 存储库中。 I googled and found the following command from www.nx.dev :我用谷歌搜索并从www.nx.dev找到以下命令:

nx generate @nrwl/nest:library util/util-myLibName

When I run the above command, then I get the following message:当我运行上述命令时,我收到以下消息:

The term 'nx' is not recognized as the name of a cmdlet, function, script file, or operable program.术语“nx”未被识别为 cmdlet、function、脚本文件或可运行程序的名称。 Check the spelling of the name, or if a path was included, verify that the path is correct and try again.检查名称的拼写,或者如果包含路径,请验证路径是否正确并重试。

I searched the web a lot, but couldn't find the solution.我搜索了很多 web,但找不到解决方案。

This is because the nx don't installed in your so这是因为 nx 没有安装在你的 so

Try first先试试

npm install -g @nrwl/cli npm 安装 -g @nrwl/cli

try尝试

npx nx generate @nrwl/nest:library util/util-myLibName

Tried the below command on Windows and it worked:在 Windows 上尝试了以下命令,它起作用了:

npm install -g nx npm 安装-g nx

https://nx.dev/getting-started/nx-setup https://nx.dev/getting-started/nx-setup

I ended up running from the local package file:我最终从本地 package 文件运行:

./node_modules/.bin/nx

Migration example: ./node_modules/.bin/nx migrate latest迁移示例: ./node_modules/.bin/nx migrate latest

I did this because installing @nrwl/cli globally did not work for me.我这样做是因为全局安装 @nrwl/cli 对我不起作用。

Instead of: nx serve而不是: nx serve

Do: npx nx serve做: npx nx serve

because npx is a package runner that can execute any package that you want from the npm registry without even installing that package. because npx is a package runner that can execute any package that you want from the npm registry without even installing that package.

Otherwise you can install nx package by using the following command:否则,您可以使用以下命令安装 nx package:

npm install --location=global nx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM