I'm using nrwl/nx monorepo in project angular as frontend and nestjs as backend api. when I'm trying to make a build os both apps angular build up and running successfully when I'm starting the nestjs main.js getting below error
Error: Cannot find module '@nestjs/common'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.@nestjs/common (/home/ubuntu/****/apps/***-api/main.js:4662:18)
at __webpack_require__ (/home/ubuntu/****/apps/****-api/main.js:20:30)
at Object../apps/*****api/src/main.ts (/home/ubuntu****-lab/apps/*****api/main.js:2997:18)
at __webpack_require__ (/home/ubuntu/*****/apps/**** api/main.js:20:30)
at Object.0 (/home/ubuntu/*****-lab/apps/*****-api/main.js:4650:18)
at __webpack_require__ (/home/ubuntu/****-lab/apps/*****-api/main.js:20:30)
As it was understood, the building and the deployment of code happened from outside where the server was located. Nx webpacks the server code to a main.js, but it doesn't bring in any of the node_modules like it does for Angular, so you still need your prod dependencies. Installing the prod dependencies on the server will fix this.