简体   繁体   English

Angular 'ng' 未被识别为内部或外部命令、可运行程序或批处理文件,无法在本地主机外访问 angular 应用程序

[英]Angular 'ng' is not recognized as an internal or external command, operable program or batch file and accessing angular app outside localhost

I am getting "'ng' is not recognized as an internal or external command, operable program or batch file."我收到“'ng' 未被识别为内部或外部命令、可运行程序或批处理文件。” when I am trying to run ng serve --host 0.0.0.0 form my command prompt.当我尝试从命令提示符运行ng serve --host 0.0.0.0时。

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但是当我通过node.js 命令提示符运行它时,我的问题解决了,我能够运行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.当我以npm 为前缀运行到 ng serve(如 github 问题中所述)时,它也运行了,我能够启动服务。 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.但是如果我将 --host 0.0.0.0 添加到 npm run ng serve ,我就会遇到问题,因为它抛出了以下错误。

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因为,我必须访问 localhost 之外的 webapp,这就是我添加 --host 0.0.0.0 的原因

Is there any better way to do, so that I can access from any system within my company.network.有没有更好的方法,以便我可以从我的 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.?发生了什么,我无法得到。?

Try running as 尝试以

D:\\NewAngular\\NewAngular\\Angular\\Feedback>npm run ng serve -- --host 0.0.0.0 D:\\ NewAngular \\ NewAngular \\ Angular \\ Feedback> npm运行ng服务---host 0.0.0.0

This will pass host argument to the command mentioned in ng serve and not npm run as such 这会将主机参数传递给ng serve中提到的命令,而不是像这样运行npm

I recommend running your terminal with root/administrative privileges.我建议使用 root/管理权限运行你的终端。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 nodejs和angular中的“'wmic.exe'不是内部或外部命令、可运行程序或批处理文件” - "'wmic.exe' is not recognized as an internal or external command, operable program or batch file" in nodejs and angular 无法将“ ng”识别为内部或外部命令,可操作程序或批处理文件。 (平均堆栈) - 'ng' is not recognized as an internal or external command, operable program or batch file. (Mean Stack) 'appium' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'appium' is not recognized as an internal or external command, operable program or batch file 无法将“ slc”识别为内部或外部命令,可操作程序或批处理文件 - 'slc' is not recognized as an internal or external command, operable program or batch file '。' 不被识别为内部或外部命令,可操作程序或批处理文件 - '.' is not recognized as an internal or external command, operable program or batch file 'express' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'express' is not recognized as an internal or external command, operable program or batch file jhipster 不是内部或外部命令,也不是可运行的程序或批处理文件 - jhipster is not recognized as an internal or external command, operable program or batch file nodemon ''mocha' 不是内部或外部命令,也不是可运行的程序或批处理文件 - nodemon ''mocha' is not recognized as an internal or external command, operable program or batch file 'ENVFILE' 不是内部或外部命令、可运行程序或批处理文件 - 'ENVFILE' is not recognized as an internal or external command, operable program or batch file 'npm' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'npm' is not recognized as internal or external command, operable program or batch file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM