I struggled to find this answer myself, as the other answers on this question do not address the real underlying issue.
All the other answers suggest to install ng
GLOBALLY using (npm i -g ...), with the side effect that a symlink to ng
will be on your PATH.
Based on OP's question, I do concede he was most likely attempting to scaffold a new Angular app from the GLOBALLY installed ng
. So this handles 90% of people's questions, and is all fine and nice.
I, however, want to use the LOCALLY INSTALLED ng
, which is why I have an npm-script
in my package.json for it:
{
...
"scripts": {
...
"ng": "ng",
...
}
If this describes your use case like it does mine, then read on.
npm run ng update
succeeds for me, whereas other more complex commands with more arguments—including command-line switches—fail outright (npm run ng -- update @angular/cli --migrate-only tslint-version-6
).
The answer lies in that you must delimit the start of arguments being passed to npm run-script
with --
(see https://stackoverflow.com/a/14404223/1438576):
npm run ng -- update @angular/cli --migrate-only tslint-version-6
So in OP's case, assuming he already had a locally-installed copy of ng
with a package.json (which I admit is doubtful), he could have done:
npm run ng -- new app
Anyway, hope this helps others.