当前位置:网站首页>[vite] Failed to parse source for import analysis because the content contains invalid JS syntax.
[vite] Failed to parse source for import analysis because the content contains invalid JS syntax.
2022-08-02 03:23:00 【懒得跟猪打架】
目录
在使用vite工具开发Vue.js 3.0项目时,由于配置问题,导致了项目运行报错,错误提示如下:
2、接着配置vite项目配置文件:vite.config.js
在使用vite工具开发Vue.js 3.0项目时,由于配置问题,导致了项目运行报错,错误提示如下:
16:17:27 [vite] page reload main.js
Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle .vue files.
16:17:28 [vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle .vue files.
Plugin: vite:import-analysis
File: /home/projects/vitejs-vite-der4uu/App.vue
这个错误的大概意思是在解析import的资源路径时出错了,因为import的内容不合法JS标识。错误提示是由vite:import-analysis报出。它还提示我们要去安装使用@vitejs/plugin-vue,这个是用来处理.vue后缀的Vue单文件组件的。
所以我们的解决方案就出来了,我们需要安装使用错误提示的插件@@vitejs/plugin-vue。
解决步骤,如下:
1、 首先安装依赖插件
npm install @vitejs/plugin-vue -D
2、接着配置vite项目配置文件:vite.config.js
// vite.config.js
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
});
这样,我们就为vite项目配置了可以识别解析.vue后缀单文件组件的功能。
3、重新运行
npm run dev
问题到此,完美解决。
bye~
边栏推荐
- 解决MySQL创建子视图并查看的时候,字符集报错问题
- 网址URL
- ImportError: libGL.so.1: cannot open shared object file: No such file or directory
- 猴子选大王(约瑟环问题)
- 1.8今日学习
- L1-020 帅到没朋友 (20分)
- 排序学习笔记(二)堆排序
- oracle inner join and outer join
- [Basic Tutorial of Remote Control Development 1] Crazy Shell Open Source Formation Drone-GPIO (Remote Control Indicator Light Control)
- nucleo stm32 h743 FREERTOS CUBE MX配置小记录
猜你喜欢
环形链表---------约瑟夫问题
querystring模块
Error in render: “TypeError: Cannot read properties of null (reading ‘0‘)“ 报错解决方案
parser = argparse.ArgumentParser() parsing
Phospholipid-polyethylene glycol-targeted neovascularization targeting peptide APRPG, DSPE-PEG-APRPG
DSPE-PEG-DBCO Phospholipid-Polyethylene Glycol-Dibenzocyclooctyne A Linear Heterobifunctional Pegylation Reagent
语义分割标签即像素值的巨坑,transforms.ToTensor()的错误使用
Small program van-cell line wrapping can be left-aligned
Scientific research reagent DMPE-PEG-Mal dimyristoylphosphatidylethanolamine-polyethylene glycol-maleimide
URL URL
随机推荐
相对路径和绝对路径
Living to detect the Adaptive Normalized Representation Learning for GeneralizableFace Anti - Spoofing reading notes
npm and package.json
js 数组去重的常用方法
第一篇博客
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
require modular syntax
Source Insight 使用教程(2)——常用功能
由中序遍历和前序遍历得到后序遍历(树的遍历)
DSPE-PEG-Silane, DSPE-PEG-SIL, phospholipid-polyethylene glycol-silane modified active group
--fs module--
display,visibility,opacity
C语言 结构体定义方法
页面加载流程
FreeRTOS内核详解(1) —— 临界段保护原理
简单黑马头条项目
L1-039 古风排版(C)
cross-domain problem solving
最新,每天填坑,Jeston TX1 精卫填坑,第一步:刷机
微信小程序怎么批量生成带参数的小程序码?