0

我有一個奇怪的問題,其中應用程序部署在AWS中時角度未定義,但本地在我的角度或JavaScript代碼中沒有問題。在AWS生產JS靜態文件問題Django應用程序

更新:

我的靜態文件(JS,CSS,圖像等)都住在S3靜態文件桶。在檢索文件時沒有任何問題,但是似乎突然間一個已經部署了幾個月的工作提交開始在加載靜態文件時引發JS問題。

下面是我的基本模板我的JS文件:

{% compress js %} 
    <script src="{{STATIC_URL}}shared/stacktrace-js/dist/stacktrace.js"></script> 
    <script src="{{STATIC_URL}}shared/jquery/2.1.1/jquery.min.js"></script> 
    <script src="{{STATIC_URL}}shared/jquery-growl/1.2.3/jquery.growl.js"></script> 
    <script src="{{STATIC_URL}}shared/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script> 
    <script src="{{STATIC_URL}}ckeditor/ckeditor-init.js"></script> 
    <script src="{{STATIC_URL}}shared/ckeditor-custom/ckeditor-custom.js"></script> 
    <script src="{{STATIC_URL}}shared/bootstrap/3.3.5/dist/js/bootstrap.min.js"></script> 
    <script src="{{STATIC_URL}}shared/utils.js"></script> 
    <script src="{{STATIC_URL}}shared/angular/1.3.11/angular.min.js"></script> 
    <script src="{{STATIC_URL}}shared/angular/1.3.11/angular-route.min.js"></script> 
    <script src="{{STATIC_URL}}shared/angular/1.3.11/angular-cookies.min.js"></script> 
    <script src="{{STATIC_URL}}shared/angular-bootstrap/0.11.0/ui-bootstrap-tpls-0.11.0.min.js"></script> 
    <script src="{{STATIC_URL}}shared/bootstrap-multiselect/bootstrap-multiselect.js"></script> 
    <script src="{{STATIC_URL}}shared/introjs/intro.js"></script> 
    <script type="text/django" src="{{STATIC_URL}}shared/ch-error-logging.js"></script> 
    <script type="text/django" src="{{STATIC_URL}}shared/ch-config.js"></script> 
    <script src="{{STATIC_URL}}shared/angulartics/dist/angulartics.min.js"></script> 
    <script src="{{STATIC_URL}}shared/angulartics-segment/dist/angulartics-segment.min.js"></script> 
    <script src="{{STATIC_URL}}shared/chart.js/dist/Chart.min.js"></script> 
    <script src="{{STATIC_URL}}shared/select2/dist/js/select2.min.js"></script> 
    <script src="{{STATIC_URL}}shared/angular-chart.js/dist/angular-chart.js"></script> 
    <script src="{{STATIC_URL}}shared/jquery-validation/dist/jquery.validate.min.js"></script> 
    <script type="text/django" src="{{STATIC_URL}}shared/ch-track.js"></script> 
    <script type="text/django" src="{{STATIC_URL}}shared/ch-file.js"></script> 
    <script src="{{STATIC_URL}}shared/offline.js"></script> 
    {% endcompress %} 

如果我改變jquery.min.js到的jquery.js的壓縮塊內部或外部,那麼其他的JS文件開始提高語法問題。通常在Chrome的控制檯錯誤說

Unexpected token (

而且在Firefox,錯誤說

SyntaxError: function statement requires a name

+0

嗨,如果你能有完整的錯誤描述更新,它會更容易一點,以找出錯誤。 '意外的標記('有點模糊 –

+0

這只是我在控制檯中得到的東西,我還有其他的錯誤說'angular is undefined',我猜這是因爲語法錯誤導致js文件加載失敗。 – nmusleh

+0

聽起來像它可能已經修復在這裏:https://github.com/django-compressor/django-compressor/pull/813,你有沒有嘗試過使用django-compressor的開發分支? – karyon

回答

0

post幫我找出哪些JS文件被壓縮造成的錯誤JS。基本上,我在指令/控制器構造方面存在問題,並且通過使用ng-strict-di,我發現了所有這些問題。

來自AngularJS ngApp文檔。 https://docs.angularjs.org/api/ng/directive/ngApp

ngStrictDi (optional) boolean if this attribute is present on the app element, the injector will be created in "strict-di" mode. This means that the application will fail to invoke functions which do not use explicit function annotation (and are thus unsuitable for minification), as described in the Dependency Injection guide, and useful debugging info will assist in tracking down the root of these bugs.

相關問題