Помогло в next.config.js добавить
config.resolve.fallback = { ...config.resolve.fallback, // https://freecode.academy/tasks/ckp9ahnondb4n0899d1cg5gwm os: require.resolve("os-browserify/browser"), }