Jig*_*try 25 typescript angular angular6
我正在Angular中构建应用程序,现在我运行了命令ng build --prod,它给了我一个dist文件夹.现在如何在Localhost上检查或提供该文件夹?
Anu*_*ara 44
你可以使用http-server来做到这一点.
首先全局安装包
npm install http-server -g.
然后在项目目录内(在终端中)运行
http-server dist/.
如果你使用角度6.xx,你必须运行
http-server dist/your-project-name
现在,您可以访问http:// localhost:8080来查看您的应用程序
小智 7
就我而言,我接下来要做的是:
全局安装http-server
npm install http-server -g
然后在项目目录中(在终端中),运行
http-server dist/[your-project-name]
现在,您可以访问http:// localhost:8080 / index.html来查看您的应用程序。但是,当我重新启动浏览器页面时,我必须再次将/index.html添加到URL中。
它可以在Angular 7.xx版本中使用。
从终端:
$ npm install http-server -g
来自 Angular 项目目录。假设您的 Angular 项目名称是 ngx。
$ ng build
$ http-server dist/ngx
启动 http-server,服务 dist/ngx
可用于:
http://127.0.0.1:8080
http://192.168.43.54:8080
按 CTRL-C 停止服务器
享受!
编辑:Angular 12+: ng serve --configuration production
从 Angular 7 开始,你可以只做ng serve --prod=true. 文档:https : //angular.io/cli/serve
我知道这个问题是关于 Angular 6 的,但 Google 把我带到了这里,所以仅供将来参考。
| 归档时间: |
|
| 查看次数: |
25555 次 |
| 最近记录: |