You need to inject a global window.jQuery first. nextjs code example
Example: You need to inject a global window.jQuery first.
module: {
rules: [{
test: require.resolve('jquery'),
use: [{
loader: 'expose-loader',
options: '$'
}]
}]
}