Immutable solution version
Notion SDK breaks Next.js 13 Vercel build: `Module not found: Can't resolve 'encoding'`
Complete solution
Shows how to fix notion SDK breaks Next.js 13 Vercel build: `Module not found: Can't resolve 'encoding'`. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "Module not found: Can't resolve 'encoding' in '.../nodemodules/node-fetch/lib'": 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'. Did Next.js 13 change something about fetch that breaks this?
Module not found: Can't resolve 'encoding' in '.../node_modules/node-fetch/lib'Steps
- 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? - This is a warning, not a real failure, and it is not specific to Next.js 13. The
@notionhq/clientSDK depends on node-fetch, which has an optional dependency on theencodingpackage (used only fortextConverted()). 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 withnpm install encoding. That is the whole fix.
When to use
You are seeing this: I am on Notion SDK 2.2.2 with Node 16/18. Use this skill when you run into "Notion SDK breaks Next.js 13 Vercel build: Module not found: Can't resolve 'encoding'".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: SDK 2.2.2. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- 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 2 · 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>