TypeError: Cannot read properties of undefined (reading ‘create’). Happens when running npm run build:ssr

Getting an error when running npm run build:ssr to try to deploy my angular application
See the code below that the error is pointing to.
I’ve been trying to figure out why is giving me that error for weeks now.

const webpack = require('webpack');
const WebpackConfigFactory = require('@nestjs/ng-universal')
  .WebpackConfigFactory;

module.exports = WebpackConfigFactory.create(webpack, {
  // Nest server for SSR
  server: './server/main.ts'
});