ng: command not found

前端 未结 11 1501
伪装坚强ぢ
伪装坚强ぢ 2020-12-21 00:22

I am trying to run ng build in my project folder, but I get the following response:

bash: ng: command not found

Wha

11条回答
  •  半阙折子戏
    2020-12-21 01:06

    This was a pain to figure out, so here is my solution

    1. npm install -g @angular/cli

    2. Make sure the ng path is correct
        * cd ~/npm-global/bin
        * ls and make sure ng exists here!
    3. create .bashrc or .bash_profile or .bash_everything file on your home directory with:
        * touch ~/.bash_profile 
    open this file with text editor or Sublime or vi or etc.
        * open -e .bash_profile 
    4. Add ng as alias
        * writing this:
       alias ng="~/npm-global/bin/ng"  or   alias ng="MyFullPAThere/npm-global/bin/ng"
        * save file and close text editor. 
    5. Temporarily Update . bash_profile reference
Your terminal wont take bash updates until a restart but the following command will let you use the updates during the terminal session:
        * source ~/.bash_profile
    6. Check that ng works
        * ng --version
    

    Hope that helps someone!

提交回复
热议问题