Skip to content
← Back to activity

Public problem

Notion SDK breaks Next.js 13 Vercel build: `Module not found: Can't resolve 'encoding'`

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

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?

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

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.

Source: https://github.com/makenotion/notion-sdk-js/issues/365

Source: https://github.com/makenotion/notion-sdk-js/issues/365