Search code examples
angularangular-console

How to run ng serve on terminal when using angular console tool?


I'am using angular console to run and test etc. my app. This working fine. But when I try to run it via terminal without using angular console, it throws the following: -bash: ng: command not found.

I made sure that the node_module is in installed via npm install under the specific project, using/installing all the dependencies.

Also when I try to run ng -v, I get the same message: -bash: ng: command not found. I assume that the global installation of @angular/cli is not correct on my machine or something similar.

I have been searching here in SO, and found kind of similar questions but I think my issue seems to be different. Also I'am not 100% sure if it has to do with angular console, but I just ask my self why it works when using angular console but not when using the terminal directly?

Any hint how to solve/fix this?


Solution

  • Issue has been solved based on the answer in the following question

    Solution:

    # create a new directory where npm will install packages
    $  mkdir ~/.node_modules
    
    # set npm "prefix" config to that directory
    $  npm config set prefix '~/.node_modules'
    
    # append a line to your .zshrc instructing it to include that directory in your $PATH, making the executables known to the shell
    $ echo 'export PATH=~/.node_modules/bin:$PATH' >> ~/.zshrc
    
    # update current shell with new path (not needed for new sessions)
    $ source ~/.zshrc