Next.js and Webpack 5

Recently, I ran into weird error messages when trying to get Next.js 10 and Webpack 5 to work:

Module parse failed: parser.isAsiPosition is not a function

Module not found: Can't resolve 'node_modules/next/node_modules/@babel/runtime/helpers/assertThisInitialized' in 'node_modules/next/dist/next-server/lib'

After a lot of hours digging around, I found the solution. Just add future: { webpack5: true } to the config in next.config.js and you’re done. Hope this helps.