0

I am getting "'ng' is not recognized as an internal or external command, operable program or batch file." when I am trying to run ng serve --host 0.0.0.0 form my command prompt.

But as I run it via node.js command prompt, my issue resolve and I was able to run ng serve --host 0.0.0.0

Another thing,

It also ran when I prefix it with npm run to ng serve (as mentioned in a github issue), I was able to bring the services up. But then I was facing issue if I add --host 0.0.0.0 to npm run ng serve as it was throwing the following error.

D:\NewAngular\NewAngular\Angular\Feedback>npm run ng serve --host 0.0.0.0

> feedback@0.0.0 ng D:\NewAngular\NewAngular\Angular\Feedback
> ng "serve" "0.0.0.0"

Project '0.0.0.0' could not be found in workspace.
Error: Project '0.0.0.0' could not be found in workspace.
at Workspace.getProject (D:\NewAngular\NewAngular\Angular\Feedback\node_modu
les\@angular-devkit\core\src\workspace\workspace.js:92:19)
at Architect.getBuilderConfiguration (D:\NewAngular\NewAngular\Angular\Feedb
ack\node_modules\@angular-devkit\architect\src\architect.js:96:41)
at MergeMapSubscriber._loadWorkspaceAndArchitect.pipe.operators_1.concatMap
[as project] 
(D:\NewAngular\NewAngular\Angular\Feedback\node_modules\@angular\cl
i\models\architect-command.js:70:55)
at MergeMapSubscriber._tryNext (D:\NewAngular\NewAngular\Angular\Feedback\no
de_modules\rxjs\internal\operators\mergeMap.js:65:27)
at MergeMapSubscriber._next (D:\NewAngular\NewAngular\Angular\Feedback\node_
modules\rxjs\internal\operators\mergeMap.js:55:18)
at MergeMapSubscriber.Subscriber.next (D:\NewAngular\NewAngular\Angular\Feed
back\node_modules\rxjs\internal\Subscriber.js:64:18)
at TapSubscriber._next (D:\NewAngular\NewAngular\Angular\Feedback\node_modul
es\rxjs\internal\operators\tap.js:62:26)
at TapSubscriber.Subscriber.next (D:\NewAngular\NewAngular\Angular\Feedback\
node_modules\rxjs\internal\Subscriber.js:64:18)
at MergeMapSubscriber.notifyNext (D:\NewAngular\NewAngular\Angular\Feedback\
node_modules\rxjs\internal\operators\mergeMap.js:84:26)
at InnerSubscriber._next (D:\NewAngular\NewAngular\Angular\Feedback\node_mod
ules\rxjs\internal\InnerSubscriber.js:25:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! feedback@0.0.0 ng: `ng "serve" "0.0.0.0"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the feedback@0.0.0 ng script.
npm ERR! This is probably not a problem with npm. There is likely additional 
logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\debjyoti.pandit\AppData\Roaming\npm-cache\_logs\201810-09
T09_24_36_064Z-debug.log

Since, I have to access the webapp outside localhost, that's why I am adding --host 0.0.0.0

Is there any better way to do, so that I can access from any system within my company network. Please help me with a proper solution.

Can anyone tell me the reason why? What is happening which I am unable to get.?

Marcus Höglund
  • 16,172
  • 11
  • 47
  • 69

2 Answers2

1

Try running as

D:\NewAngular\NewAngular\Angular\Feedback>npm run ng serve -- --host 0.0.0.0

This will pass host argument to the command mentioned in ng serve and not npm run as such

Danon
  • 2,771
  • 27
  • 37
Hari Prathap
  • 102
  • 7
0

I recommend running your terminal with root/administrative privileges.

Danon
  • 2,771
  • 27
  • 37
Diego
  • 2,238
  • 4
  • 31
  • 68