002 vue3-admin项目的目录及文件说明之tsconfig.node.json文件
说明
tsconfig.node.json 是现代前端项目中常见的 TypeScript 配置文件,专门用于 Node.js 环境的代码配置。
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}
核心配置
1 compilerOptions 属性
项目引用相关配置
"compilerOptions": {
"composite": true,
"skipLibCheck": true
}
模块配置
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
}
类型检查配置
"compilerOptions": {
"strict": true
}
2 include 属性
"include": ["vite.config.ts"]
完整示例分析
典型的 tsconfig.node.json
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true,
"noEmit": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"include": ["vite.config.ts", "env.d.ts", "build/**/*.ts"]
}
配置项说明
与项目引用的关系
项目引用结构
project/
├── tsconfig.json # 主配置文件
│ ├── "references": [
│ ├── { "path": "./tsconfig.app.json" },
│ ├── { "path": "./tsconfig.node.json" }
│ ├── ]
├── tsconfig.app.json # 应用代码配置
├── tsconfig.node.json # Node.js 代码配置
└── vite.config.ts # Vite 配置文件
工作原理

浙公网安备 33010602011771号