简体   繁体   English

Nginx中的Angular 4应用无法加载文件

[英]Angular 4 app in nginx unable to load file

I have deployed angular 4 app using nginx. 我已经使用Nginx部署了angular 4应用程序。 But its unable to load js,css and other files. 但是它无法加载js,css和其他文件。 I see these error in console 我在控制台中看到这些错误

Uncaught SyntaxError: Unexpected token < inline.bundle.js:1 未捕获到的SyntaxError:意外令牌<inline.bundle.js:1

Uncaught SyntaxError: Unexpected token < polyfills.bundle.js:1 未捕获到的SyntaxError:意外的令牌<polyfills.bundle.js:1

Uncaught SyntaxError: Unexpected token < scripts.bundle.js:1 未捕获到的SyntaxError:意外的令牌<scripts.bundle.js:1

Uncaught ReferenceError: webpackJsonp is not defined at styles.bundle.js:1 styles.bundle.js:1 (anonymous) @ styles.bundle.js:1 未被捕获的ReferenceError:未在styles.bundle.js:1处定义webpackJsonp。styles.bundle.js:1(匿名)@ styles.bundle.js:1

Uncaught SyntaxError: Unexpected token < vendor.bundle.js:1 未捕获到的SyntaxError:意外的令牌<vendor.bundle.js:1

Uncaught ReferenceError: webpackJsonp is not defined at main.bundle.js:1 main.bundle.js:1 未捕获的ReferenceError:未在main.bundle.js:1上定义webpackJsonp。main.bundle.js:1

My nginx configuration: 我的nginx配置:

 server {
     listen 80 default_server;
     listen [::]:80 default_server;


     root /var/www/html;

     # Add index.php to the list if you are using PHP
     index index.html index.htm index.nginx-debian.html;

     server_name _;
      location / {
             # First attempt to serve request as file, then
             # as directory, then fall back to displaying a 404.
             #alias /web-portal/;

             root /var/www/html/web-portal/;
             try_files  $uri$args $uri$args/  /index.html =404;
     }

 }

Kindly Help Me to solve This !! 请帮助我解决这个问题!

It seems to be a duplicate of " Syntax Error in Angular App: Unexpected token < ". 它似乎与“ Angular App中的语法错误:意外令牌< ”重复。

Please check (and/or share us) your base href attribute in your project. 请检查(和/或与我们分享)您项目中的base href属性。

It could be related to your issue. 这可能与您的问题有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM