【问题标题】:How to properly deploy angular application (based on ngBoilerplate and using nginx)?如何正确部署 Angular 应用程序(基于 ngBoilerplate 并使用 nginx)?
【发布时间】:2015-06-03 15:30:10
【问题描述】:

我发现,ngBoilerplate 非常容易在基于 Angular 的 Web 开发中迈出第一步。没错,我正在尝试准备我的部署管道,所以我使用 github、travis-ci 和 dockerized nginx 映像。

我认为要正确部署我的简单 Angular 网站,我只需要:

git clone https://github.com/ngbp/ngbp.git
cd ngbp/
npm install
bower install
grunt compile

然后复制bin/目录:

bin/
├── assets
│   ├── ngbp-0.3.2.css
│   ├── ngbp-0.3.2.js
│   └── README.md
└── index.html

到nginx目录/usr/share/nginx/html/.

很遗憾,javascript 代码有问题。我有错误

Error: $injector:nomod
Module Unavailable

https://docs.angularjs.org/error/$injector/nomod?p0=ngBoilerplate.home

我做错了什么?

【问题讨论】:

  • 这似乎是正确的,在我的脑海中。如果您打开开发者控制台,您是否看到任何网络错误?您能确认一下网络标签中的脚本内容吗?
  • @JoshDavidMiller:请看一下我的短截屏视频:youtube.com/watch?v=yjBcKT2tgAk
  • compile 任务假定您已经运行了build 任务。只需运行 grunt 即可。 github.com/ngbp/ngbp#build-vs-compile

标签: javascript angularjs nginx deployment ngboilerplate


【解决方案1】:

在 ngbp 中,Grunt 任务被分解为two categories:构建和编译。构建任务完成运行站点所需的一切,尤其是在开发过程中,编译任务连接并缩小文件以用于生产。

您的问题是您没有运行构建任务,编译任务需要它才能运行。为了节省时间(见上面的链接),这些是分开的。如果你想从头到尾,包括缩小,只需运行grunt,相当于运行grunt build compile

自述文件假定您使用grunt buildgrunt watch 进行所有开发,之后您可以在部署之前简单地运行grunt compile

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-04
    • 2011-10-15
    • 2012-10-13
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    • 1970-01-01
    相关资源
    最近更新 更多