I get an error when building project

When I run the npm run build command I get an error
error TS6305: Output file '.../vite.config.d.ts' has not been built from source file '../vite.config.ts'.
The file is in the program because:
Matched by include pattern 'vite.config.ts' in '.../tsconfig.json'

tsconfig.json:28:22
28 "include": ["src", "vite.config.ts"],
~~~~~~~~~~~~~~~~
File is matched by include pattern specified here.


Found 1 error.
error TS6305: Output file '.../vite.config.d.ts' has not been built from source file '../vite.config.ts'.
The file is in the program because:
Matched by include pattern 'vite.config.ts' in '.../tsconfig.json'

tsconfig.json:28:22
28 "include": ["src", "vite.config.ts"],
~~~~~~~~~~~~~~~~
File is matched by include pattern specified here.


Found 1 error.
Here are the contents of my files vite.config.ts
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [react()],
});
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [react()],
});
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
},
"include": ["src", "vite.config.ts"],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
},
"include": ["src", "vite.config.ts"],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
3 Replies
kapa.ai
kapa.ai2mo ago
Hi @Щербина Даниил. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It looks like you're encountering an issue with your tsconfig.json file when trying to build your project using npm run build. The error message indicates that the vite.config.ts file is included in the TypeScript compilation but hasn't been built from the source file. To resolve this issue, you can try the following steps: 1. Check the include field in tsconfig.json: Ensure that the vite.config.ts file is correctly included in the include field of your tsconfig.json. Your current configuration seems correct, but let's double-check it:
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src", "vite.config.ts"],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}

{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src", "vite.config.ts"],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}

2. Ensure Vite Configuration: Make sure your vite.config.ts file is correctly set up. Your current configuration looks fine:
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [react()],
});

import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [react()],
});

3. Check for TypeScript Configuration Issues: Sometimes, issues can arise from the TypeScript configuration itself. Ensure that there are no conflicting settings in your tsconfig.json. 4. Run the Build Command: If the above steps don't resolve the issue, try running the build command again. If you still encounter errors, consider using the refine CLI to build your project, as mentioned in the Discord support thread (https://discord.com/channels/837692625737613362/1208733702008602655):
npm run refine build

npm run refine build

5. Check for Import Issues: Ensure that all your imports are correctly set up and that there are no imports from /dist/ or other non-standard paths, as suggested in the Discord support thread (https://discord.com/channels/837692625737613362/1208733702008602655). If you follow these steps and still encounter issues, please provide more details about your setup, and we can further investigate the problem. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@146219191421108224> kapa.ai is still learning and improving, please let us know how it did by reacting below
ambitious-aqua
ambitious-aqua2mo ago
Hey @Щербина Даниил