I've built an express app using npx nx g @nx/express:app user-service and two libs using npx nx g @nx/js:lib shared-structures and npx nx g @nx/js:lib services while services has a dependency to shared-structures like so:
While running the app via npx nx serve my-express-api is just working fine and the build npx nx build my-express-api does not produce any errors but tells me that everything went fine, i am not able to get that built bundle running with node main.js inside the folder where the bundle is located.
This is what happens:
Error: Cannot find module 'services'
I also added the paths in the tsconfig.base.json file:
Note again, that serving via npx nx serve user-service works fine. Building via npx nx build user-service does not produce any errors and creates such folder structure:
dist
|-apps
|--user-service
|---main.js
|---main.js.map
|-libs
|--services (with all expected contents)
|--shared-structures (with all expected contents)
But running node dist/apps/user-service/main.js results in:
Current Behavior
I've built an express app using
npx nx g @nx/express:app user-service
and two libs usingnpx nx g @nx/js:lib shared-structures
andnpx nx g @nx/js:lib services
while services has a dependency toshared-structures
like so:project.json
ofuser-service
:package-json
ofuser-service
:package.json
ofservices
:project.json
ofservices
:While running the app via
npx nx serve my-express-api
is just working fine and the buildnpx nx build my-express-api
does not produce any errors but tells me that everything went fine, i am not able to get that built bundle running withnode main.js
inside the folder where the bundle is located.This is what happens:
I also added the paths in the
tsconfig.base.json
file:package.json
of the monorepo:nx.json
:Summary:
npx nx serve my-express-api
works finenpx nx build my-express-api
seems also to work since it does not produce any errorsnode main.js
(main.js
is the name of the bundle) does produce the error aboveExpected Behavior
I'd expect the bundle to be able to get started via
node main.js
orpm2 start main.js
. Neither works due to the error described above.GitHub Repo
No response
Steps to Reproduce
nx g @nx/express:app my-express-api
nx g @nx/js:lib my-lib
nx g @nx/js:lib my-lib2
my-lib
a dependency ofmy-lib2
(inpackage.json
:"my-lib": "*"
)nx build my-express-api
node main.js
(inside the folder wheremain.js
is locatedNx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
Note again, that serving via
npx nx serve user-service
works fine. Building vianpx nx build user-service
does not produce any errors and creates such folder structure:But running
node dist/apps/user-service/main.js
results in: