How to rename an Angular project?

前端 未结 5 702
北荒
北荒 2021-01-03 19:51

I renamed my Angular 4 project folder from auction-life to auction-05-life and replaced 3 occurrences of the old project name in:

相关标签:
5条回答
  • 2021-01-03 20:16

    If you are not familiar with bash scripting but with your IDE, you always can perform recursive search in your files (usually Ctrl+Shift+F) and replace it everywhere - Ctrl+Alt+Enter on VSCode. Visual Studio Code Example

    0 讨论(0)
  • 2021-01-03 20:19

    As of this writing, the Angular-cli commandline doesn't do renaming. So, this is what i did (manually):

    1. First, see how really invested the old name is in the project by searching the "old name". On Linux, i used simple grep as.

    grep -ir "oldname" .
    

    That showed so many files, most of them under /node_modules. So i removed the /node_modules (and will use npm install after i finish the rename).

    2. Next, i did Linux find & replace command against the files in current folder as follows (source sited at bottom):

    cd your folder
    sed -i 's/oldName/newName/g' *
    

    Finally, don’t forget to do npm install on the current directory to install dependencies listed in your package.json (remember we removed node_modules that had old name)

    ** Credits:

    Find replace "sed" command is from: How to replace a string in multiple files in linux command line

    0 讨论(0)
  • 2021-01-03 20:20
    1. Search in your project wherever the old name is used.
    2. In Visual Studio Code search can be done by using the search bar provided.
    3. Replace old name with your new name.
    4. Rename the project folder name as well and you are done.
    5. If some error occurs while running your project , delete the node_modules and do "npm install".Everything will be fine and running again.
    0 讨论(0)
  • 2021-01-03 20:24

    With macOS you go to your angular project folder, and use sed command to replace old name by the new that you want:

    LC_CTYPE=C && LANG=C && find * -type f -exec sed -i "" "s/old-angular-project-name/new-name/g" {} +
    
    0 讨论(0)
  • 2021-01-03 20:30

    Modify Project name in angular.json file & also project folder name. Delete 'node_modules' folder from your project directory. Then run npm install command.Finally run ng serve command.

    0 讨论(0)
提交回复
热议问题