module not found: Error: Can't resolve 'pnpapi' in '/app/node_modules/next/dist/lib'

Viewed 1050

I tried building my next.js app and encountered this error which broke my app.

module not found: Error: Can't resolve 'pnpapi' in '/app/node_modules/next/dist/lib'

> Build error occurred
Error: > Build failed because of webpack errors
   at build (/app/node_modules/next/dist/build/index.js:15:918)
   at process._tickCallback (internal/process/next_tick.js:68:7
1 Answers
const { HotModuleReplacementPlugin } = require("webpack");

This import appeared in my code, in the index of my application. I removed it and webpack was working again.

Related