[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.。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

在使用vite工具开发Vue.js 3.0项目时,由于配置问题,导致了项目运行报错,错误提示如下:

解决步骤,如下:

1、 首先安装依赖插件

2、接着配置vite项目配置文件:vite.config.js

3、重新运行


在使用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~文章来源地址https://www.toymoban.com/news/detail-676256.html

到了这里,关于[vite] Failed to parse source for import analysis because the content contains invalid JS syntax.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Job for mysqld.service failed because the control process exited with error code.

    通过百度翻译如下: mysqld.service 的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅 “systemctl status mysqld.service” 和 “journalctl -xe”。 得到的结论时与进程相关 先查询一下mysql的进程 直接简单粗暴的吧红框的两个进程杀掉 每个人的进程号都不一样,注意

    2024年01月17日
    浏览(36)
  • Job for network.service failed because the control process exited with error code.

    Linux Centos7 修改为静态iP后重启网络服务遇到的问题 重启网络:service network restart                   /etc/init.d/network restart 报错问题描述:Job for network.service failed because the control process exited with error code. See \\\"systemctl status network.service\\\" and \\\"journalctl -xe\\\" for details.   查看 cat /etc/sy

    2024年02月08日
    浏览(37)
  • Job for DmServiceDMSERVER.service failed because the control process exited with error code.

    Job for DmServiceDMSERVER.service failed because the control process exited with error code. See \\\"systemctl status DmServiceDMSERVER.service\\\" and \\\"journalctl -xe\\\" for details. 这个报错是发生测试数据库备份恢复功能时。系统环境 麒麟linuxV10 + 达梦V8。 备份全库,停止  system stop DmServiceDMSERVER console 界面选择刚做的全

    2024年02月13日
    浏览(29)
  • Job for nginx.service failed because the control process exited with error code.

    1. nginx启动报错: 这个错误是nginx.conf配置文件里面配置错误,可以使用命令检查在哪里出错 出错的地方: 进行改正,并再次检查。输出以下信息表示ok。 启动nginx: 建议每次更改配置文件都先执行命令检查一下配置文件是否配置成功。 2.nginx相关命令 查看nginx启动状态 重启加

    2024年02月15日
    浏览(42)
  • 关于Job for network.service failed because the control process exited with error code.

    重启网络出现报错 Job for network.service failed because the control process exited with error code. See \\\"systemctl status network.service\\\" and \\\"journalctl -xe\\\" for details. 1.执行systemctl restart network.service命令后出现下面的错误 2.按照报错提示输入了systemctl status network.service 3.解决方法 3.1网络配置工具network和

    2024年02月11日
    浏览(56)
  • vue3+vite+vant项目下按需引入vant报错Failed to resolve import解决方案

    在学习vite+vue3+vant开发项目过程中, 参考vant官网开发指南-快速上手-引入组件 vant组件库官网 按照上述配置好后,运行vite环境报错:Failed to resolve import 根据报错信息,发现是vant的样式引入路径不对。 以 Button 组件为例 程序解析为:项目路径/node_modules /vant/lib /vant/es/button/s

    2024年02月15日
    浏览(41)
  • 【mysql 错误】Job for mysqld.service failed because the control process exited with error code

    mysql 报错信息如下:Job for mysqld.service failed because the control process exited with error code. See “systemctl status mysqld.service” and “journalctl -xe” for details.是什么原因,如何解决 这个错误提示比较笼统,需要查看具体的日志才能确定问题所在。你可以通过以下步骤来获取更详细的错误信

    2024年01月17日
    浏览(40)
  • Unity “Failed to create agent because it is not close enough to the NavMesh“警告 并由此引发的问题

    这个报错表示的意思是:NavMeshAgent所在节点未放置在寻路网格上 从最基本的理解上,就是说你的角色,或者某个 agent 没有在导航的地形上, 最关键的是:由此引发的报错: \\\"SetDestination\\\" can only be called on an active agent that has been placed on a NavMesh. 导致角色无法移动。 我找了很久

    2024年02月13日
    浏览(41)
  • nginx重启失败:Job for nginx.service failed because the control process exited with error code

    前言 因为项目的ssl证书快过期了,所以去重新申请替换了,避免https无法使用。替换证书文件后重启nginx发现报错。 报错提示: 1. 运行status命令查看: systemctl status nginx 很明显这里是说80端口已被占用,说明有相应的进程在运行,找到进程将其关闭即可! 2. 执行命令:sudo ki

    2024年04月27日
    浏览(34)
  • Docker服务启动时报错:Job for docker.service failed because the control process exited with error

    初学docker,遇见报错信息: Job for docker.service failed because the control process exited with error code. See \\\"systemctl status docker.service\\\" and \\\"journalctl -xe\\\" for details. 方法一: 有可能版本内核没问题 还是这样的话,就是容器引擎失败。 1. 修改 /etc/docker/daemon.json { \\\"storage-driver\\\": \\\"devicemapper\\\" } 2. 修改

    2024年02月05日
    浏览(47)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包