1.下载依赖包
npm install @types/node --save
2.修改vite.config.ts配置文件
import path from "path";
export default defineConfig({plugins: [vue()],resolve: {alias: {"@": path.resolve(__dirname, "./src"),},},
});
3.修改tsconfig.json配置文件
{"compilerOptions": {// ........ 其他配置项"baseUrl": "./","paths": {"@/*": ["src/*"]},},"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],"references": [{ "path": "./tsconfig.node.json" }]
}