vite+vue3项目,安装vite后
1.main.ts文件报错
import { createApp } from 'vue'
import App from './App.vue'
英文错误信息:“Cannot find module ‘vue’. Did you mean to set the ‘moduleResolution’ option to ‘node’, or to add aliases to the ‘paths’ option?ts(2792)”,
2.tsconfig.config.json文件报错
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
英文错误信息: “JSON schema for the TypeScript compiler’s configuration file Option ‘–resolveJsonModule’ cannot be specified without ‘node’ module resolution strategy.ts”
解决方法
在tsconfig.config.json文件添加:
"moduleResolution": "node"