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

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/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