【发布时间】:2018-01-24 04:01:32
【问题描述】:
我创建了一个简单的 Angular 应用程序,它现在由 npm start(开发模式)在我的 Linux 服务器上提供服务
这里的问题是无法通过浏览器访问。 4200端口也开放了。
该应用程序通过地址http://localhost:4200在本地计算机上完美运行。
现在我尝试通过http://xxx.xx.xx.xx:4200访问服务器上的应用
这是npm start 命令运行时的控制台输出。
> client@0.0.0 start /var/www/html/node1/social2/client
> ng serve
Unable to find "@angular/cli" in devDependencies.
The package "angular-cli" has been deprecated and renamed to "@angular/cli".
Please take the following steps to avoid issues:
"npm uninstall --save angular-cli"
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-01-23T19:40:09.118Z
Hash: 0698820565e2563b7f26
Time: 16593ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 178 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 550 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 33.8 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 9.15 MB [initial] [rendered]
webpack: Compiled successfully.
这可能是什么原因?
【问题讨论】:
-
如果您想隐藏您的 IP,您可能需要更新该屏幕截图。
-
您需要在 0.0.0.0 上进行监听才能让外部访问它。
-
在package.json中更新
start为ng serve --host 0.0.0.0github.com/angular/angular-cli/issues/3765 -
你自己已经问过两次同样的问题了。你在做什么
标签: javascript angularjs node.js