0

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?

k.vincent
  • 3,743
  • 8
  • 37
  • 74
  • Seems like problem with your angular-cli installation. Run `which ng` and see if it is installed properly. – rvkant Jul 02 '19 at 08:18
  • When I run `which ng`, there is no output at all. But I can see that I do have a node_module folder globally and also under the specific project folder. It also has the sub folder: `@angular/cli`. This is kind of strange. – k.vincent Jul 02 '19 at 08:22
  • The global installation seems to be broken. Please install it again using `npm install -g @angular/cli`. – rvkant Jul 02 '19 at 08:26
  • This is what I thought and I did install a specific version globally using `npm install -g @angular/cli@7.0.6` and it throws: `[fsevents] Success: "/Users/myUserName/node_modules/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote + @angular/cli@7.0.6`. And after that, when I run `ng verve`, `ng -v` I get `-bash: ng: command not found` and when I run `which ng`, there is no output at all. I assume something is not working correctly even if it says: `[fsevents] Success:...` – k.vincent Jul 02 '19 at 08:34
  • Possible duplicate of [ng: command not found while creating new project using angular-cli](https://stackoverflow.com/questions/37227794/ng-command-not-found-while-creating-new-project-using-angular-cli) – B.Benjo Jul 02 '19 at 12:50
  • This is not a duplicated question. It looks like but it's not. Please read my question carefully and check the details. Anyway, I have solved the issue based on this question: (https://stackoverflow.com/questions/42323442/install-for-angular-cli-not-working-on-mac). The answer of Sinan. If there is no answer or hint from your side, please, don't just mark a question as duplicated. – k.vincent Jul 02 '19 at 12:58

1 Answers1

0

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
k.vincent
  • 3,743
  • 8
  • 37
  • 74