当前位置:网站首页>[plugin:vite:import-analysis]Failed to resolve import “@/“ from ““.Does the file exist

[plugin:vite:import-analysis]Failed to resolve import “@/“ from ““.Does the file exist

2022-06-23 09:29:00 Feng ruye

Screenshot of error reporting :
 Insert picture description here
Error reason : Not configured @ The symbol specifies the path alias for , Lead to direct use

Solution :

Install first path modular

npm install --save-dev @types/node

modify vite.config.js file

import {
     defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
    
  plugins: [vue()],
  resolve: {
    
    alias: {
    
      '@': path.resolve(__dirname, 'src')
    }
  }
})

Rerun the project

npm run dev
原网站

版权声明
本文为[Feng ruye]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230927380521.html