Encountering an error while trying to build my Astro Project using npm run build
, or when navigating to one of my markdown pages after running: npm run dev
. The error message is as follows:
> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="80e1f3f4f2efade2ecefe7adf4e5edf0ece1f4e5c0b0aeb0aeb1">[email protected]</a> build
> astro build
17:42:55 [build] output target: static
17:42:55 [build] Collecting build info...
17:42:55 [build] Completed in 47ms.
17:42:55 [build] Building static entrypoints...
[vite:esbuild] failed to resolve "extends":"astro/tsconfigs/strict" in C:\Users\felix\documents\programmieren\hhh\tsconfig.json
file: C:/Users/felix/documents/programmieren/hhh/src/utils/getPostData.ts
error failed to resolve "extends":"astro/tsconfigs/strict" in C:\Users\felix\documents\programmieren\hhh\tsconfig.json
File:
C:/Users/felix/documents/programmieren/hhh/src/utils/getPostData.ts
Stacktrace:
at resolveExtends (file:///C:/Users/felix/Documents/Programmieren/hhh/node_modules/astro/node_modules/vite/dist/node/chunks/dep-5cb728cb.js:13162:9)
at parseExtends (file:///C:/Users/felix/Documents/Programmieren/hhh/node_modules/astro/node_modules/vite/dist/node/chunks/dep-5cb728cb.js:13135:34)
at parse$g (file:///C:/Users/felix/Documents/Programmieren/hhh/node_modules/astro/node_modules/vite/dist/node/chunks/dep-5cb728cb.js:13086:24)
js:13557:24)
at async transformWithEsbuild (file:///C:/Users/felix/Documents/Programmieren/hhh/node_modules/astro/node_modules/vite/dist/node/chunks/dep-5cb728cb.js:13280:36)
at async Object.transform (file:///C:/Users/felix/Documents/Programmieren/hhh/node_modules/astro/node_modules/vite/dist/node/chunks/dep-5cb728cb.js:13379:32)
at async transform (file:///C:/Users/felix/Documents/Programmieren/hhh/node_modules/rollup/dist/es/shared/rollup.js:21911:16)
at async ModuleLoader.addModuleSource (file:///C:/Users/felix/Documents/Programmieren/hhh/node_modules/rollup/dist/es/shared/rollup.js:22136:30)
The issue seems to be related to the tsconfig.json file, prompting me to switch it from:
{
"compilerOptions": {
// Enable top-level await, and other modern ESM features.
"target": "ESNext",
"module": "ESNext",
// Enable node-style module resolution, for things like npm package imports.
"moduleResolution": "node",
// Enable JSON imports.
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
// Astro will directly run your TypeScript code, no transpilation needed.
"noEmit": true
},
"extends": "astro/tsconfigs/strict"
}
To:
{
"extends": "astro/tsconfigs/strict",
"include": ["**/*.ts", "**/*.tsx", "**/*.jsx"],
"exclude": ["node_modules", "studio"],
"compilerOptions": {
"types": ["astro/client"],
"target": "ESNext",
"module": "ESNext",
// Enable node-style module resolution, for things like npm package imports.
"moduleResolution": "node",
// Enable JSON imports.
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
// Astro will directly run your TypeScript code, no transpilation needed.
"noEmit": true,
"baseUrl": "/",
"paths": {
"@components/*": ["src/components/*"],
"@layouts/*": ["src/layouts/*"]
}
}
}
After making this change, running npm run dev
seemed to partially fix the problem, but the error persisted with npm run build
. As I am relatively new to TypeScript, a detailed explanation would be greatly appreciated. The project's source code can be found on GitHub.
How can I troubleshoot and resolve this error?