vue cli - 未捕获的语法错误:意外标记 < [英] vue cli - Uncaught SyntaxError: Unexpected token <
问题描述
我使用 vue-cli 3.0
创建我的项目.最初它运行正常.但是在我
然后 npm run serve
之后,它继续抛出错误:
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:
Uncaught SyntaxError: Unexpected token <
Uncaught SyntaxError: Unexpected token <
它表明错误发生在 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
我该如何解决这个问题?
How can I resolve this?
更新01我再次删除了整个 node-modules
文件夹和 npm install
,然后一切似乎又正常了.但如果有人知道为什么会发生这种情况,请分享.
Update01
I 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.
推荐答案
尝试将 > 你的 index.html.希望它会起作用.
Try by adding <base href="/" />
into the <head>
of your index.html. Hope it will work.
这篇关于vue cli - 未捕获的语法错误:意外标记 <的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!