本文介绍了vue cli-未捕获的SyntaxError:意外令牌<的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 vue-cli 3.0 创建我的项目.最初它运行正常.但是在我< ctrl> -c 之后, npm再运行一次发球服务,它总是抛出错误:

I create my project with vue-cli 3.0. Initially it runs ok. But after I <ctrl>-c then npm run serve again, it keep throwing error:

它指示错误发生在 app.js 的第一行,但是我在控制台中检查< 实际上是来自 index.html .这意味着在此过程的某个地方, webpack 认为 index.html 应该转换为 app.js .

it indicate that the error happened at the first line of app.js, but I check in console the < is actually from index.html. Which means somewhere along the process, the webpack thought index.html should be transpile as app.js.

以下是我正在使用的软件包:

Below are the packages I am using:

vue 3.0.0-rc.3@ vue/cli-plugin-babel ^ 3.0.0-beta.15@ vue/cli-plugin-eslint ^ 3.0.0-beta.15@ vue/cli-service ^ 3.0.0-beta.15

vue 3.0.0-rc.3@vue/cli-plugin-babel ^3.0.0-beta.15@vue/cli-plugin-eslint ^3.0.0-beta.15@vue/cli-service ^3.0.0-beta.15

我该如何解决?

Update01 我再次删除了整个 node-modules 文件夹,并再次 npm install ,然后一切似乎都可以正常工作了.但是,如果有人知道为什么会发生这种情况,请分享.

Update01I delete the whole node-modules folder and npm install again, then everything seems to work fine again. But if anyone have any idea why this happen, please share it.

推荐答案

尝试通过在< head> 中添加< base href ="/"/> >您的index.html.希望它能工作.

Try by adding <base href="/" /> into the <head> of your index.html. Hope it will work.

这篇关于vue cli-未捕获的SyntaxError:意外令牌&lt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 01:03