bash ng command not found mac ng serve works for me only the time when I just installed
ng serve works for me only the time when I just installed, after that I opened new terminal and after navigating to the angular project directory and try to run ' ng serve ' at that time the terminal is showing 'bash ng command not found'
Works well for me 1. Link cli to npm: npm link @angular/cli
Set the location of npm folder: export PATH="$HOME/.npm-global/bin:$PATH"
Clear cache and re-install cli: npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli
Give alias to ng path : alias ng="/Users/Dharshini/.npm-global/lib/node_modules/@angular/cli/bin/ng"
Go back to the base user: cd ~
Change path using vim: sudo vim /etc/paths
Add ~/.npm-global/bin to the end of the file. type i to insert type :wq to save and exit
restart terminal and type: echo $PATH
Finally know the version using: ng version
My solution: Node modules resides in the directory /opt/node/bin
Add these two lines to your .bashrc file NODE_BIN="/opt/node/bin" export PATH="$PATH:$NODE_BIN"
Save and close .bashrc and run: source .bashrc
.... Currently, both node and npm runs without being referenced in .bashrc, but that is because the executable files for node and npm are located in /usr/local/bin directory which itself is by default on the $PATH. So, instead of adding the 'ng' executable to /usr/local/bin, I exported /opt/node/bin to my path instead, to prevent any other modules in the future from not being found.
For solving this issue
-bash: ng: command not found
you need to set PATH, follow these steps and you'll be good to go:
export PATH="$HOME/.npm-global/bin:$PATH" export PATH="$HOME/.npm-packages/bin:$PATH"
npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli
Give an alias to ng Path-
PATH = /Users/Dharshini/.npm-global/lib/node_modules/@angular/cli/bin/ng
alias ng="PATH"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.