bash /usr/bin/ng: No such file or directory in Angular

前端 未结 8 2198
故里飘歌
故里飘歌 2020-12-16 15:55

When I run my Angular project by ng serve, it gives this error:

bash: /usr/bin/ng: No such file or directory

I have

相关标签:
8条回答
  • 2020-12-16 16:14

    I faced the same problem and here is what worked for me.

    1. Find the .bashrc file by running ls -la ~/ | more
    2. Open in editor, in my case emacs emacs ~/.bashrc
    3. Add an alias at the end of the file like this pointing to the right path of your ng directory alias ng="/usr/local/lib/node_modules/@angular/cli/bin/ng" 4.save the file and install it by running sudo source ~/.bashrc

    Now test by running ng -v

    0 讨论(0)
  • 2020-12-16 16:18

    Looks like you had run npm install -g @angular/cli with root. Try to remove angular-cli and then reinstall with sudo

    sudo npm remove -g @angular/cli
    sudo npm install -g @angular/cli
    
    0 讨论(0)
  • 2020-12-16 16:28

    Use this command ,I resolved my issue after angular cli installed

    alias ng="/usr/local/lib/node_modules/@angular/cli/bin/ng"

    0 讨论(0)
  • 2020-12-16 16:30

    I reinstalled angular and then restarted the terminal. It worked fine

    0 讨论(0)
  • 2020-12-16 16:35

    I've run into this issue when @agnular/cli is intended to be installed on CI.

    I resolved this by simply creating an empty folder just before you're about to execute any of ng-related commands

    $ mkdir node_modules
    $ ng --version
    
    0 讨论(0)
  • 2020-12-16 16:36

    Run this in root
    $ sudo su

    # sudo npm install -g @angular/cli

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