[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项目时,由于配置问题,导致了项目运行报错,错误提示如下:

Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle .vue files.
12:08:44 [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.

解决方法

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()],
});

3、重新运行

npm run dev

解决!文章来源地址https://www.toymoban.com/news/detail-572686.html

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

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

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

相关文章

  • SpringBoot微服务项目报错:Failed to process import candidates for configuration class [springfox.boot...

    [main] ERROR org.springframework.boot.SpringApplication - Application run failed org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [springfox.boot.starter.autoconfigure.OpenApiAutoConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [springfox/document

    2024年01月17日
    浏览(56)
  • vite打包报错:await import(‘source-map-support‘).then((r) => r.default.install())(亲测有效)

    先看一下报错  我是在Jenkins上执行发布时报的错,本地是可以打包的 这种情况一般是依赖出了问题,然后删除依赖重新下载,即可,如果不行就是node版本过低,vite2要求node版本= 12.0.0,但是vite3要求node版本 14.18+,16+,如果删除依赖不能解决问题使用node - v查看node版本

    2024年02月11日
    浏览(35)
  • 成功解决RuntimeError: Failed to import transformers.models.llama.tokenization_llama_fast because of the

    成功解决RuntimeError: Failed to import transformers.models.llama.tokenization_llama_fast because of the following error (look up to see its traceback): tokenizers=0.13.3 is required for a normal functioning of this module, but found tokenizers==0.12.1 目录 解决问题 解决思路 解决方法 T1、pip命令 T2、conda命令 RuntimeError: Failed to im

    2024年02月11日
    浏览(34)
  • vue3+vite的项目报错 await import(‘source-map-support‘).then((r) => r.default.install()) ^^^^^Synta

      await import(\\\'source-map-support\\\').then((r) = r.default.install())     ^^^^^ SyntaxError: Unexpected reserved word  查看一下node版本  报错原因是node版本的问题。要使用16之上的版本 我的电脑安装了nvm可以查看目前已有的node版本。不会安装nvm的参考这个

    2024年02月15日
    浏览(31)
  • ES报错— Unable to parse response body for Response

    在调用es java客户端,执行新增es文档时报错:Unable to parse response body for Response ​ ​​ 返回201,表示插入成功 可以在kibana查询新增数据 ‍ 原因分析: 老版本es客户端无法解析新版es的返回,有可能是 spring-boot 版本低了,没有做这方面的处理(数据是能保存进 es 的,而且 e

    2024年03月27日
    浏览(35)
  • ES报错 Unable to parse response body for Response

    报错信息: 此处是项目中使用 ES ,向其中插入数据 虽然项目报错,但是 ES 中成功存入了数据,且此处可以看到返回的是 200 OK 报错原因: 原因是因为 es 服务器的响应程序解析不了,有可能是 spring-boot 版本低了,没有做这方面的处理 我的 es 是 8.4.3 版本的,spring-boot 是 2.

    2024年02月11日
    浏览(30)
  • Vue3报错:Failed to fetch dynamically imported module

    Vue3报错:Failed to fetch dynamically imported module解决 翻译:获取动态导入的模块失败 目前发现三个能够导致此报错出现的原因 (未完待续): ①是路由路径错误 ②路由路径正确,但是缺少文件(写了路由没写文件) ③路由路径正确,但是文件名错误,导致找不到文件 在我没找

    2024年02月13日
    浏览(44)
  • SpringBoot整合Elasticsearch报错:Unable to parse response body for Response

    具体报错: 原因: 根据官方提供的文档,选择SpringBoot支持的Elasticsearch对应版本 Elasticsearch的迭代太快了,springboot不一定支持,导致我使用Elasticsearch 8.0的时候报错,根据你的springboot版本更换掉对应的Elasticsearch 版本即可 下面是官方提供的Elasticsearch对应springboot版本,具体地

    2024年02月11日
    浏览(33)
  • This application failed to start because no Qt platform plugin could be initialized报错

    开机后电脑一直跳出这个页面,每隔几分钟就跳出,影响电脑的使用。 由于本机近几天并未下载软件、移动文件位置等操作,只有下载安装Anaconda,于是我将这个原因归结于Anaconda安装上。为了学习opencv我下载了opencv-python的主模块包和PyQt5。 由于我经验不足,学习了在CSDN上大

    2024年02月02日
    浏览(37)
  • vue3使用Vite打包报Rollup failed to resolve import “xxx/node_modules/ant-design-vue/xxxx

    在使用vue3 + vite + ant design vue 的时候,引入一些antd的一些组件的时候,通常运行是没有错的,但是打包会报错,例如: Rollup failed to resolve import \\\"D:/xxxxx/node_modules/ant-design-vue/es/form-item-rest/style/index\\\" from \\\"src/views/xxx/xxx.vue\\\". 15:01:51 This is most likely unintended because it can break your applic

    2024年02月16日
    浏览(33)

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

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

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

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

二维码1

领取红包

二维码2

领红包