Skip to content

Lỗi Starlight Plugins Config - Expected type "object", received "array"

[AstroUserError] Invalid plugins config passed to starlight integration
Hint:
0: Expected type "object", received "array"

Lỗi này xảy ra khi bạn cấu hình plugins trong Starlight dưới dạng array ([]) thay vì object ({}).

// ❌ Sai - dạng array
plugins: [
starlightPluginIcons(),
starlightMarkdownBlocks({ ... }),
],
// ✅ Đúng - dạng object
plugins: {
starlightPluginIcons: starlightPluginIcons(),
starlightMarkdownBlocks: starlightMarkdownBlocks({ ... }),
},

Tuy nhiên: Phiên bản mới của @astrojs/starlight có thể không hỗ trợ plugins theo cách này. Tham khảo Starlight Plugins Documentation để biết cách cấu hình đúng.

Nếu không cần thiết, xóa plugins khỏi cấu hình:

export default defineConfig({
integrations: [
starlight({
title: 'My Docs',
customCss: ['./src/styles/custom.css'],
// Không có plugins
}),
],
});

Kiểm tra phiên bản đang sử dụng:

Terminal window
npm list @astrojs/starlight

Đảm bảo sử dụng phiên bản mới nhất:

Terminal window
npm update @astrojs/starlight

Xem Starlight Plugins để biết cách cấu hình đúng cho phiên bản bạn đang dùng.