ng: command not found while creating new project using angular-cli

后端 未结 30 2893
忘掉有多难
忘掉有多难 2020-11-28 23:42

Installed angular-cli globally using (npm install -g angular-cli) but when I\'m trying to create project using ng new my-project it is throwing err

30条回答
  •  野性不改
    2020-11-29 00:15

    This is how I made it worked for me :).

    1 - npm link @angular/cli

    It will return you the path of cli, which will look like this

    /usr/local/Cellar/node/11.3.0_1/lib/node_modules/@angular/cli
    

    For this part, /11.3.0_1 please replace this with your respective node version that can be found by typing node --version

    2 - cd ~/

    3 - open .bash_profile

    In the bash profile create an alias for cli like this,

    alias ng="/usr/local/Cellar/node/11.3.0_1/lib/node_modules/@angular/cli/bin/ng"

    4 - source ~/.bash_profile

    This is how your .bash_profile will look like once you add alias to it.

    Now typing ng in the terminal will display output shown in attached snapshot.

    I hope this answer will be helpful.

提交回复
热议问题