Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Angular“ng”未被识别为内部或外部命令、可操作程序或批处理文件,无法在localhost外部访问Angular应用程序_Node.js_Angular_Npm_Npm Install - Fatal编程技术网

Node.js Angular“ng”未被识别为内部或外部命令、可操作程序或批处理文件,无法在localhost外部访问Angular应用程序

Node.js Angular“ng”未被识别为内部或外部命令、可操作程序或批处理文件,无法在localhost外部访问Angular应用程序,node.js,angular,npm,npm-install,Node.js,Angular,Npm,Npm Install,我收到的“ng”未被识别为内部或外部命令, 可操作的程序或批处理文件。当我试图从命令提示符运行ng SERVICE-host 0.0.0.0时 但是当我通过node.js命令提示符运行它时,我的问题解决了,并且我能够运行ng serve-host 0.0.0 还有一件事 当我在它前面加上npm run to ng serve时,它也运行了,正如github一期中提到的,我能够启动服务。但是,如果我将-host 0.0.0.0添加到npm运行ng serve中,我将面临一个问题,因为它会抛出以下错

我收到的“ng”未被识别为内部或外部命令, 可操作的程序或批处理文件。当我试图从命令提示符运行ng SERVICE-host 0.0.0.0时

但是当我通过node.js命令提示符运行它时,我的问题解决了,并且我能够运行ng serve-host 0.0.0

还有一件事

当我在它前面加上npm run to ng serve时,它也运行了,正如github一期中提到的,我能够启动服务。但是,如果我将-host 0.0.0.0添加到npm运行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
因为,我必须在localhost之外访问webapp,所以我添加了-host 0.0.0.0

是否有更好的方法,以便我可以从公司网络内的任何系统访问。 请帮我找到一个合适的解决办法

谁能告诉我原因吗?发生了什么我无法了解的情况?

尝试以

D:\NewAngular\NewAngular\Angular\Feedback>npm运行ng服务--主机0.0.0.0


这会将主机参数传递给ng serve而非npm run中提到的命令,因此

使用ipconfig查找您的IP并使用它,而不是0.0.0 try ng serve-host非0.0.0我已尝试使用IP和direct ng serve-host,但它不起作用。请仔细阅读问题。我想你没有正确阅读我的问题。@DebjyotiPandit我的建议是添加-tweed D D:\NewAngular\NewAngular\Angular\Feedback>npm run ng serve--host 0.0.0当我删除了-和host之间的空格时,它起作用了。在这种情况下,当你添加-时,它会将后续参数传递给npm scripting serve中提到的脚本请参考:谢谢你的帮助