首页IT科技vitenma(【Vite】使用报错合集)

vitenma(【Vite】使用报错合集)

时间2025-06-20 10:47:27分类IT科技浏览4487
导读:1.npm install 报错...

1.npm install 报错

解决方法:运行下列命令即可

npm audit fix --force

 2.vite创建vue3项目报错

报错:Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle .vue files.

 解决方法:

        1)安装 @vitejs/plugin-vue

npm i @vitejs/plugin-vue

        2)重新 npm install

npm install

        3)添加配置文件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()] })

        4)重新运行即可

npm run dev

3.improt引入文件报错

报错:无法找到模块“../views/HomeView.vue              ”的声明文件              。“/Users/lianwei/Desktop/old/PersonalProject/vite-demo2/src/views/HomeView.vue.js                    ”隐式拥有 "any" 类型                    。

解决方法:找到src/vite-env.d.ts 添加以下代码

// 在文件中加上 declare module *.vue { import type { DefineComponent } from vue const component: DefineComponent<{}, {}, any> export default component } // 或者 declare module *.vue { import type { DefineComponent } from vue const component: ComponentOptions | ComponentOptions[setup] export default component }

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
西瓜视频答题赚钱(什么游戏网站注册送钱-玩西瓜视频答题游戏撸钱,三个臭皮匠赛过诸葛亮,抱团取暖轻松日赚500+) win10命令窗口怎么调出来快捷键(win10怎么调出命令行? win10运行cmd命令的方法)