当前位置:网站首页>Vite configuring path aliases in the project
Vite configuring path aliases in the project
2022-07-28 13:53:00 【Shadow wind Mo】
vite Add vue3 Report errors in the project Cannot find module 'XXXXXX ’ or its corresponding type declarations
We only need to configure in the following files :
vite.config.ts:
Pay attention to the use of node Of path The module needs to execute npm i --save-dev @types/node command
import {
defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
const path = require('path');
export default defineConfig({
plugins: [vue()],
define: {
'process.env': {
},
},
resolve: {
// Configure path alias
alias: {
'@': path.resolve(__dirname, './src'),
},
},
});
tsconfig.json:
To configure baseUrl,paths
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
It's done ! Next you can use @ Alias represents src The absolute path of
边栏推荐
- 我秃了!唯一索引、普通索引我该选谁?
- C language: random number + quick sort
- 7. Dependency injection
- JWT 登录认证 + Token 自动续期方案,写得太好了!
- 朋友发来几个面试题
- I'm bald! Who should I choose for unique index or general index?
- Merge table rows - three levels of for loop traversal data
- R language ggplot2 visualization: use the ggviolin function of ggpubr package to visualize violin diagrams, set the palette parameter, and customize the border colors of violin diagrams at different l
- Excellent performance! Oxford, Shanghai, AI Lab, Hong Kong University, Shangtang, and Tsinghua have joined forces to propose a language aware visual transformer for reference image segmentation! Open
- Today's sleep quality record 75 points
猜你喜欢

Socket类关于TCP字符流编程的理解学习

算法---不同路径(Kotlin)

Go language - Application of stack - expression evaluation

SQL每日一练(牛客新题库)——第4天:高级操作符

不用Swagger,那我用啥?

The domestic API management tool eolink is very easy to use, creating an efficient research and development tool

DXF读写:对齐尺寸标注文字居中、上方的位置计算

7.依赖注入

No swagger, what do I use?

30天刷题计划(四)
随机推荐
你真的了解esModule吗
What if the server cannot be connected (the original server cannot find the target resource)
数据库系统原理与应用教程(059)—— MySQL 练习题:操作题 1-10(三)
国产API管理工具Eolink太好用了,打造高效的研发利器
Generation of tables and contingency tables (cross tables) of R language factor data: use the summary function to analyze the list, view the chi square test results, and judge whether the two factor v
ES6 what amazing writing methods have you used
安全保障基于软件全生命周期-NetworkPolicy应用
Tutorial on the principle and application of database system (060) -- MySQL exercise: operation questions 11-20 (IV)
数据库系统原理与应用教程(058)—— MySQL 练习题(二):单选题
掌握闭包,夯实基本功
算法---不同路径(Kotlin)
vite在项目中配置路径别名
Three men "running away" from high positions in the mobile phone factory
C language: quick sorting of sequential storage structure
How to play a data mining game entry Edition
使用 IPtables 进行 DDoS 保护
R language uses LM function to build multiple linear regression model, writes regression equation according to model coefficient, and uses conflict function to give 95% confidence interval of regressi
Dojp1520 gate jumping problem solution
不用Swagger,那我用啥?
C language: merge sort