2017-03-10 10 views
0

私はng-cli v1.0.0-beta.32.3を使用しています。アプリケーションをローカルでテストしたところ、すべてが機能します。 Webサーバー(nginx v1.10.1)に展開する準備ができました。私は以下のように私のアプリケーションを構築しました。ng-cliで作成されたAngular 2アプリケーションのデプロイメントが機能しない

ng build -prod 

次のように私はその後/etc/nginx/nginx.confをインストールし、変更します。これは、server_namerootの値を除くデフォルトの設定です。

user nginx; 
worker_processes auto; 
error_log /var/log/nginx/error.log; 
pid /var/run/nginx.pid; 

include /usr/share/nginx/modules/*.conf; 

events { 
    worker_connections 1024; 
} 

http { 
    log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
         '$status $body_bytes_sent "$http_referer" ' 
         '"$http_user_agent" "$http_x_forwarded_for"'; 

    access_log /var/log/nginx/access.log main; 

    sendfile   on; 
    tcp_nopush   on; 
    tcp_nodelay   on; 
    keepalive_timeout 65; 
    types_hash_max_size 2048; 

    include    /etc/nginx/mime.types; 
    default_type  application/octet-stream; 

    include /etc/nginx/conf.d/*.conf; 

    index index.html index.htm; 

    server { 
     listen  80 default_server; 
     listen  [::]:80 default_server; 
     server_name mydomain.io www.mydomain.io; 
     root   /data/myapp-www; 

     # Load configuration files for the default server block. 
     include /etc/nginx/default.d/*.conf; 

     location/{ 
     } 

     error_page 404 /404.html; 
      location = /40x.html { 
     } 

     error_page 500 502 503 504 /50x.html; 
      location = /50x.html { 
     } 
    } 
} 

私はウェブサイトにアクセスしようとすると、次のメッセージが表示されます。

 
EXCEPTION: Uncaught (in promise): Error: DI Error 
Error: DI Error 
    at e.d (http://www.mydomain.io/polyfills.d946e5067bfdbad71862.bundle.js:36:2213) 
    at e [as constructor] (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:470:508) 
    at e [as constructor] (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:926:228) 
    at new e (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:926:555) 
    at t._throwOrNull (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:1247:2766) 
    at t._getByKeyDefault (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:1247:3104) 
    at t._getByKey (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:1247:2485) 
    at t.get (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:1247:848) 
    at e.get [as _CookieService_62] (http://www.mydomain.io/main.d6b9261dcd8e4e58fa99.bundle.js:5:23993) 
    at e.get [as _PersistenceService_63] (http://www.mydomain.io/main.d6b9261dcd8e4e58fa99.bundle.js:5:24234) 
    at e.get [as _mydomainService_64] (http://www.mydomain.io/main.d6b9261dcd8e4e58fa99.bundle.js:5:24488) 
    at e.getInternal (http://www.mydomain.io/main.d6b9261dcd8e4e58fa99.bundle.js:5:28132) 
    at e.get (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:668:1102) 
    at e.t.injectorGet (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:113:1750) 
    at e.get (http://www.mydomain.io/vendor.92d15c6580f9163ad6fb.bundle.js:1254:350) 
t.handleError @ vendor.92d15c6….bundle.js:654 
next @ vendor.92d15c6….bundle.js:456 
e.object.o @ vendor.92d15c6….bundle.js:661 
e.__tryOrUnsub @ vendor.92d15c6….bundle.js:1 
e.next @ vendor.92d15c6….bundle.js:1 
e._next @ vendor.92d15c6….bundle.js:1 
e.next @ vendor.92d15c6….bundle.js:1 
e.next @ vendor.92d15c6….bundle.js:8 
e.emit @ vendor.92d15c6….bundle.js:661 
t.triggerError @ vendor.92d15c6….bundle.js:379 
onHandleError @ vendor.92d15c6….bundle.js:379 
t.handleError @ polyfills.d946e50….bundle.js:36 
n.runGuarded @ polyfills.d946e50….bundle.js:36 
r @ polyfills.d946e50….bundle.js:36 
i @ polyfills.d946e50….bundle.js:36 

私のindex.htmlファイルは次のようになります。

<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>My App</title> 
    <base href="/"> 

    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="icon" type="image/x-icon" href="favicon.ico"> 
<link href="styles.4d956e5c8b5af5fd67b3.bundle.css" rel="stylesheet"/></head> 
<body> 
    <app-root></app-root> 
<script type="text/javascript" src="inline.8ba963ff286f59f238cc.bundle.js"></script><script type="text/javascript" src="polyfills.d946e5067bfdbad71862.bundle.js"></script><script type="text/javascript" src="scripts.bb730b805dc244f77e93.bundle.js"></script><script type="text/javascript" src="vendor.92d15c6580f9163ad6fb.bundle.js"></script><script type="text/javascript" src="main.d6b9261dcd8e4e58fa99.bundle.js"></script></body> 
</html> 
+0

ng-cli RCにアップグレードすることを検討してください。 –

+0

私が使用しているバージョンにバグはありますか? ng-cliをアップグレードするたびに、プロジェクトの構造が変更されたかどうか、新しいこと、または異なることがあります。 –

+0

@JaneWayne私は知っていますが、ベータ版です。 – Kilmazing

答えて

0

FWIW、私はng2-cookiesangular2-cookieから切り替えることで、この問題を解決しました。私はangular2-cookieからCookieServiceを宣言して注射していましたが、この依存症はすべての頭痛を引き起こしていました。この依存関係を単に削除して(そしてクッキーを操作する代わりにng2-cookiesを使用した)、この問題は解決しませんでした。私は問題を深く掘り下げる時間がなかったが、私にとってはこのように問題を回避した。

関連する問題