简体   繁体   English

在 NX 工作区中创建 NestJS 控制器和模块

[英]Creating NestJS Controllers and Modules in a NX Workspace

I am using the NX workspace's angular-nest boilerplate to get started with an App.我正在使用 NX 工作区的 angular-nest 样板来开始使用应用程序。 Whenever I try to use the CLI or the NX extension to generate a controller/module etc, it gets placed in the wrong folder.每当我尝试使用 CLI 或 NX 扩展来生成控制器/模块等时,它都会被放置在错误的文件夹中。

https://i.imgur.com/MbOhdgU.png https://i.imgur.com/MbOhdgU.png

For instance, if I generate a new module for nest, I would like it to be placed in api/src as that is where the Nest files are.例如,如果我为嵌套生成一个新模块,我希望将它放在api/src中,因为那是嵌套文件所在的位置。 But in my case if I use the command nest generate module helloworld , it gets placed in the src/helloworld folder outside of the api/src folder.但在我的情况下,如果我使用命令nest generate module helloworld ,它将被放置在api/src文件夹之外的src/helloworld文件夹中。

Is there a simpler way to make it so that my Nest components and modules etc are generated in the Nest folder and Angular components etc are in the Angular folder?有没有更简单的方法可以让我的 Nest 组件和模块等在 Nest 文件夹中生成,Angular 组件等在 Angular 文件夹中?

use the "NX console" extension ( which I see you already installed... )使用“NX 控制台”扩展(我看到你已经安装了......) 在此处输入图像描述 将“data-store-api”替换为嵌套js项目名称

If you don't want to use the nx console in VSCode, you can also run the command nx g @nrwl/nest:controller <controller-name> -p <project-name> .如果不想在 VSCode 中使用 nx 控制台,也可以运行命令nx g @nrwl/nest:controller <controller-name> -p <project-name> Check out the docs on the @nrwl/nest generators and their options查看@nrwl/nest生成器及其选项的文档

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

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