Node "serve" target does not build dependencies that are buildable, or watch for changes
See original GitHub issueCurrent Behavior
If you set up an NodeJS application which has a lib dependency in the workspace which is “buildable” then when you run nx serve your-app
the lib will not be automatically built, and the serve will fail because its expecting to find the built output of the lib in the `dist/ directory.
If you nx build your-app
it will build the dependency properly.
If you are “serving” the app after building the lib manually, it will not rebuild or restart the app if the lib is changed
Expected Behavior
I would expect that the lib is automatically built by running nx serve
on the node app. I would also expect it to be watching for changes to the lib and automatically re-running the server.
Steps to Reproduce
The issue is reproduced in my public Nx repo here: https://github.com/devcyclehq/js-sdks
If you run nx serve example-nodejs-cloud-typescript
then it will fail, because it can’t find the built output of the dependency in the dist/
directory.
Failure Logs
Environment
NX Report complete - copy this into the issue template
Node : 16.13.2
OS : darwin x64
yarn : 3.2.0
nx : 14.0.5
@nrwl/angular : Not Found
@nrwl/cypress : 14.0.5
@nrwl/detox : 14.0.5
@nrwl/devkit : 14.0.5
@nrwl/eslint-plugin-nx : 14.0.5
@nrwl/express : Not Found
@nrwl/jest : 14.0.5
@nrwl/js : 14.0.5
@nrwl/linter : 14.0.5
@nrwl/nest : Not Found
@nrwl/next : 14.0.5
@nrwl/node : 14.0.5
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : 14.0.5
@nrwl/react-native : 14.0.5
@nrwl/schematics : Not Found
@nrwl/storybook : 14.0.5
@nrwl/web : 14.0.5
@nrwl/workspace : 14.0.5
typescript : 4.6.3
rxjs : 6.6.7
Issue Analytics
- State:
- Created a year ago
- Comments:5
I’m on Mac OS and experiencing the issue, so I don’t think that’s the culprit
I ran into this and was able to solve it by updating my nx.json. Now if one of my apps depends on my library that has a generate target, it will automatically run on serve and build. I hope this helps someone.