I am currently developing a NestJS application using Yarn Berry as the package manager, and I have encountered an issue.
I would like to run the already built files directly using the node dist/main.js
command in the production environment instead of using the yarn start
command. However, an error occurs when I try to do this.
In fact, I faced a similar issue before. When using the default NestJS nest command, I encountered errors like Cannot find module
for all import statements, such as import { Module } from '@nestjs/common';
, when using the nest start
command. To resolve this, I installed the VSCode-specific Yarn SDKs and started using the yarn start
command instead of nest, which allowed the application to run without any issues.
However, in the production environment, it is more efficient to run the already built files directly instead of using the yarn start
command. When I use node dist/main.js
, I get the error Error: Cannot find module '@nestjs/common'
.
For those developing NestJS applications with Yarn Berry, how do you run the built files in a production environment?