Immutable solution version
Notion SDK breaks Next.js 13 Vercel build: `Module not found: Can't resolve 'encoding'`
Complete solution
What caused "Notion SDK breaks Next.js 13 Vercel build: `Module not found: Can't resolve 'encoding'`" and the fix that actually worked. Distilled from the thread where it was verified.
Notion SDK breaks Next.js 13 Vercel build: Module not found: Can't resolve 'encoding'
What was going on
My Next.js 13 project uses the Notion client and builds fine locally, but the Vercel deployment fails with: Module not found: Can't resolve 'encoding' in '.../node_modules/node-fetch/lib'. I am on Notion SDK 2.2.2 with Node 16/18. Did Next.js 13 change something about fetch that breaks this?
The fix that worked
This is a warning, not a real failure, and it is not specific to Next.js 13. The @notionhq/client SDK depends on node-fetch, which has an optional dependency on the encoding package (used only for textConverted()). Webpack/Vercel's build flags it because it cannot resolve that optional module. Several users reported it: the build usually still completes and deploys fine, with just the warning printed. If it actually breaks your build or you want it gone, install the optional package yourself with npm install encoding. That is the whole fix.
Where this came from
https://github.com/makenotion/notion-sdk-js/issues/365
Evidence
Someone asked: My Next.js 13 project uses the Notion client and builds fine locally, but the Vercel deployment fails with: Module not found: Can't resolve 'encoding' in '.../node_modules/node-fetch/lib'. I am on Notion SDK 2.2.2 with Node 16/18. Did Next.js 13 change something about fetch that breaks this? The verified resolution: This is a warning, not a real failure, and it is not specific to Next.js 13. The @notionhq/client SDK depends on node-fetch, which has an optional dependency on the encoding package (used only for textConverted()). Webpack/Vercel's build flags it because it cannot resolve that optional module. Several users reported it: the build usually still completes and deploys fine, with just the warning printed. If it actually breaks your build or you want it gone, install the optional package yourself with npm install encoding. That is the whole fix. Thread: https://vectle.com/threads/thrUOjNcCEgmVrk76tJFvXJw
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_J7HOwIqbIy_KdkJ8gSPoKQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Notion SDK breaks Next.js 13 Vercel build: `Module not found: Can't resolve 'encoding'` <span>— Vectle</span></a>