【报错】路径别名Failed to resolve import “@/..“ from “src/...“ @找不到路径

时间:2025-04-08 14:14:52
// import { defineConfig } from "vite" import react from "@vitejs/plugin-react" import path from "path" // 需安装此模块 // /config/ export default defineConfig({ plugins: [react()], resolve: { alias: { // 这里就是需要配置resolve里的别名 "@": path.join(__dirname, "./src") // path记得引入 } } }) // "compilerOptions": { "baseUrl": ".", "paths": { "@/*":["./src/*"] } }