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.

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s