I have a Nrwl Nx repo with different apps (angular, nodejs with express) and shared libs inside.
The repo was created with the nx cli
and I want to build for production one of the express
apps.
nx build:production myexpressapp
The bundle I get is very nice and runs if I run it (with pm2) from where it was built (dist
folder).
However, if I get it to production, the node modules are missing and the app does not start.
If I copy the node_modules folder above the one with the built dist it works as well.
But I would very much like either of:
I tried using "vendorChunk":true
in my production build options but nothing changes.
Any thoughts?
Looking at angular.json
(or workspace.json
), if your builder
is @nrwl/node:build
, under options
, set externalDependencies
to none
, like so:
{
"projects": {
"api": {
"architect": {
"build": {
"builder": "@nrwl/node:build",
"options": {
"externalDependencies": "none"
...
You may experience errors like:
ERROR in ...
Module not found: Error: Can't resolve 'some-modules' in ...
Just keep installing what its complaining about, until it stops.
Reference: Nrwl Nx Node Builder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With