You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js 13 TypeScript中Contentful导入报错:createClient导出不存在

解决Contentful客户端创建的导入错误

问题原因

Contentful SDK的createClient是默认导出,而非命名导出,所以你用花括号的命名导入方式会触发这个错误。另外你的代码里还有一个拼写错误:accesToken应该是accessToken(少了一个s),这个错误会导致后续API请求失败,必须修正。

修复后的代码

import createClient from "contentful";

const client = createClient({
  space: "*", // 替换为你的Contentful空间ID
  accessToken: "*", // 替换为你的Contentful访问令牌,注意拼写修正
});

export default client;

额外说明

如果需要使用Contentful的其他工具方法(比如createPreviewClient),可以结合命名导入的方式:

import createClient, { createPreviewClient } from "contentful";

内容的提问来源于stack exchange,提问作者nurdan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 15:40:36