Search code examples
nestjs

How to create the "src/app" instead of the "src" directory with "nest new"


This command will create the "helloworld/src" directory.

nest new helloworld

These 5 files are created in the "helloworld/src" directory:

app.controller.spec.ts
app.controller.ts
app.module.ts
app.service.ts
main.ts

How to create the same files in the "src/app" instead of the "src" directory? i.e. "helloworld/src/app" instead of the "helloworld/src" directory


Solution

  • With nest new, you don't. This is the CLI's opinion on how you should have your app set up. If you want to move things afterwards, you can always do nest new <args> && mkdir src/app && mv src/* src/app assuming your shell expands on * like zsh does, otherwise you can use a find command and execute a mv on each found file under src, or create your own executable to create a Nest project