vue3-vite安裝后main.ts文件和tsconfig.app.json文件報錯解決辦法
報錯現(xiàn)象:
安裝vite后“main.ts” 和 “tsconfig.app.json” 文件報錯
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import router from './router'
安裝vite后,“main.ts” 文件中這幾行出現(xiàn)了報錯,如圖所示:

鼠標移動到報錯位置,顯示提示:
“Cannot find module ‘vue’. Did you mean to set the ‘moduleResolution’ option to ‘node’, or to add aliases to the ‘paths’ option?ts(2792)”,
如圖所示:

“tsconfig.app.json” 文件也會報錯,如圖:

鼠標移動到報錯的紅色下劃線位置,出現(xiàn)錯誤提示 “JSON schema for the TypeScript compiler’s configuration file
Option ‘–resolveJsonModule’ cannot be specified without ‘node’ module resolution strategy.ts”,如圖:

解決方法
根據(jù)報錯提示:“Cannot find module ‘vue’. Did you mean to set the ‘moduleResolution’ option to ‘node’, or to add aliases to the ‘paths’ option?ts(2792)”,
在 “tsconfig.app.json” 文件 的"compilerOptions" 選項中添加配置- - -“moduleResolution”: “node”,添加后保存文件,“main.ts” 和 “tsconfig.app.json” 文件中的報錯就消失了。

總結
到此這篇關于vue3-vite安裝后main.ts文件和tsconfig.app.json文件報錯解決辦法的文章就介紹到這了,更多相關vue3-vite安裝后文件報錯內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Vue3響應式數(shù)據(jù)轉回原始普通對象的方法詳解
本文介紹了在Vue中,如何使用toRaw將響應式數(shù)據(jù)轉回原始普通對象,核心應用場景包括與第三方庫兼容、性能優(yōu)化、避免無限遞歸、只讀不觸發(fā)響應式等,文中詳細解釋了響應式數(shù)據(jù)與原始數(shù)據(jù)的區(qū)別,并提供了轉回原始數(shù)據(jù)的方法和注意事項,需要的朋友可以參考下2026-04-04
vue3+ts數(shù)組去重方及reactive/ref響應式顯示流程分析
這篇文章主要介紹了vue3+ts數(shù)組去重方法-reactive/ref響應式顯示,本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-04-04

