Angular 应用程序中的语法错误:意外令牌 < [英] Syntax Error in Angular App: Unexpected token &lt;

查看:20
本文介绍了Angular 应用程序中的语法错误:意外令牌 <的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Angular 应用程序,它可以在我的本地和生产环境中完美运行.在我做了一个小小的改变之后,我在本地运行了这个应用程序,它运行良好.然后我构建了这个项目并将 dist 文件夹复制到 Web 服务器.问题是当我尝试访问该应用程序时,我在 Chrome Inspector 中收到以下错误:

I have an Angular app which runs perfectly in my local and production environment.. After a tiny change I made, I ran the app locally and it works fine.. Then I built the project and copied the dist folder to the web server. The problem is when I try to access to the app I get the following error in the Chrome Inspector:

Uncaught SyntaxError: Unexpected token < inline.1a152b6….bundle.js:1
Uncaught SyntaxError: Unexpected token < polyfills.1553fdd….bundle.js:1
Uncaught SyntaxError: Unexpected token < vendor.94d0113….bundle.js:1
Uncaught SyntaxError: Unexpected token < main.d6f56a1….bundle.js:1

因此,它似乎是一个放错位置的字符,但在我的本地环境中,该应用程序运行良好,我在控制台上没有收到任何警告或错误消息..

So, it seems like it is a misplaced character but in my local environment the app works fine I don't get any warning or error message on the console..

推荐答案

这很可能是 404 页面或重定向到提供常规 html 而不是预期的 JavaScript 文件的页面的结果.(HTML 页面以 开头)

This is most likely the result of a 404 page or a redirect to a page that serves regular html instead of the expected JavaScript files. (A HTML page starts with <html> or a <!DOCTYPE...>)

确保您已正确上传文件并正确访问页面.您可以通过使用浏览器手动访问 URL 进行验证,或者查看浏览器开发工具的网络选项卡以检查响应.

Make sure that you have correctly uploaded the files and access the page correctly. You can verify by manually accessing the URL with the browser or look into the network tab of your browser development tools to inspect the response.

这篇关于Angular 应用程序中的语法错误:意外令牌 <的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆