NX workspace, how to change an Angular app name with the the cli?
Asked Answered
H

2

23

I have NX workspace with some apps and the product decided to change one of the apps name, how can I do it without manually change the app's folders names, modules names, all the importing paths, NX settings etc'?

Same app, same location, only different name.

Haim answered 24/11, 2020 at 13:54 Comment(0)
H
59

Since Nx 8.12 you can do it by using the move schematic (or mv) to 'move' the app to the same place but with the new wanted name.

For example, if I want to rename my 'oldNG' app to be called 'newNG', I can do that like so:

nx g @nrwl/workspace:move --project oldNG newNG

Or nx g mv --project oldNG newNG if I want to rename app from my default collection. (provisioned in angular.json).

If I want to move this app to different place- I just need to include the destination in the new name of the app, like so:

nx g @nrwl/workspace:move --project oldNG destination/newNG

Read more: https://nx.dev/latest/angular/plugins/workspace/schematics/move

Haim answered 24/11, 2020 at 13:54 Comment(1)
this will rename the folder, but the project will keep the same nameBrahui
B
2

Use @nx/workspace:move

For example:

nx g @nx/workspace:move --projectName old-project-name --destination apps/new-project-name --newProjectName new-project-name

This commad move and rename your project.

Read more: https://nx.dev/nx-api/workspace/generators/move

Bremen answered 12/11, 2023 at 7:39 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.