How to fix Angular ng: not found
Problem:
When trying to run a command like ng build
, e.g. in a CI setup, you see an error message like
sh: ng: not found
Preferred solution:
Only the machine where you’re running this command, you have not installed the ng
command globally.
However, your node_modules
folder will have a local installation of @angular/cli
.
In order to use it, replace ng
by ./node_modules/.bin/ng
.
For example, a scripts
section of your package.json
"scripts": {
"build": "ng build"
},
would be replaced by
"scripts": {
"build": "./node_modules/.bin/ng build"
},
Alternative solution:
Install ng
globally on the machine running the command by using
sudo npm i -g @angular/cli