How to correctly build NestJS app for production with node_modules dependencies in bundle?

陌路散爱 提交于 2020-02-21 13:46:28

问题


After nest build or nest build --webpack dist folder does not contain all required modules and I got Error: Cannot find module '@nestjs/core' when trying to run node main.js.

I could not find any clear instructions on https://docs.nestjs.com/ on how to correctly build app for production, so maybe I missed something?


回答1:


Out of the box, nest cli does not support including the node_modules dependencies into the dist bundle.


However, there are some community examples of custom webpack configs that include the dependencies in the bundle, e.g. bundled-nest. As described in this issue, it is necessary to include the webpack.IgnorePlugin to whitelist unused dynamic libraries.



来源:https://stackoverflow.com/questions/59635276/how-to-correctly-build-nestjs-app-for-production-with-node-modules-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!