Angular App中的语法错误:意外令牌< [英] Syntax Error in Angular App: Unexpected token <

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

问题描述

我有一个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页面以<html><!DOCTYPE...>开头)

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 App中的语法错误:意外令牌&lt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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