已经配置如下代码安装了@types/node
import path from "path";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
proxy: {
"/api": {
target: "http://localhost:3000",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});
并且tsconfig.json中配置了如下解析还是报错,同时没有别名提示
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": ["./src/*"]
}
},
给如图两个json中添加相同的别名配置如下
测试可以解决别名不提示,和@引入一直爆红的问题