You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

引入Vue的createApp时遇到模块解析错误及语法错误的问题求助

引入Vue的createApp时遇到模块解析错误及语法错误的问题求助

各位大佬好,我刚上手Vue项目搭建,现在碰到了两个搞不定的错误,想请教下怎么解决。

我写了最基础的入口文件代码:

import { createApp } from "vue"
import App from "./App.vue"

createApp(App).mount("#app")

运行之后控制台直接报错:

Uncaught TypeError: Failed to resolve module specifier "vue". Relative references must start with either "/", "./", or "../".

我明明已经提前执行过npm install vue命令安装Vue了啊...

后来我试着把index.html里的type="module"属性去掉,结果又跳出来另一个错误:

Uncaught SyntaxError: Cannot use import statement outside a module

现在卡在这儿了,有没有朋友能指点一下问题出在哪儿呀?

备注:内容来源于stack exchange,提问作者Da Krabs Koder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 09:13:11