New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"generatePackageJson" does not include dependencies from libs/*
#6840
Comments
I guess you can try to wrap it by something then import it? |
@hiepxanh I'm not understanding. The package.json should include all possible dependencies needed for the app. |
I'm having the same issue - I have a Node.js based app which uses a lib that imports {
"name": "services-subgraphs-people",
"version": "0.0.1",
"dependencies": {
"type-graphql": "^1.1.1",
"graphql": "^15.5.1",
"@typegoose/typegoose": "^8.2.0",
"mongoose": "^5.13.8",
"mongoose-lean-id": "^0.2.0",
"tslog": "^3.2.1",
"reflect-metadata": "^0.1.13",
"aws-sdk": "^2.977.0",
"apollo-server": "^3.3.0"
},
"main": "main.js"
} Meaning that when I run it, I get an error message stating that |
I had the exact same problem with the Removing the |
Duplicate of #5820 |
@vsavkin @jeffbcross 'generatePackageJson' is not found in schema in latest would you have a solution to this? Seems like it's not documented in anywhere. |
@HackPoint can you provide a simple reproduce? |
It was a simple yarn create nx-workspace pure angular project which is not created a simple workspace.json file even. |
@HackPoint oh you're talking about initializing a new workspace with the Angular preset would yield this error? |
Actually tried it on an Empty project: added angular app and a single library and it's gives me the same error. |
@HackPoint Thank you. What is the command that triggers the error? A build command? or a run command? |
nx run :build:production after I have added "generatePackageJson": true to project.json |
|
|
I need to control versioning on explicit application for allowing different versions on each build. For allowing me push different distributions to different pops. |
+1, can't find any doc and facing the same issue |
I ran into this issue and it turns out I had a dependency listed in both However, once I removed them from the |
Has anyone found any solutions for that? |
Make sure you updated to the current version of the executor(s). For example A few of them were renamed here: #9086 That said, I still have the issue outlined in the initial issue, and even with some packages that are not part of my code base they aren’t being picked up in a nest project despite being directly imported in non-unit test code paths. |
I needed this functionality as well and accomplished it by writing my own executor. Within an executor you can do: import { readCachedProjectGraph } from "@nrwl/devkit";
const { dependencies } = readCachedProjectGraph(); and the |
So I took a look at that, at least one of my issues seems to stem from the project graph, so looking more into that. Looking at the dependencies that are output is missing one of my imports entirely. We have n+1 nx monorepos. We use a commons one to publish the majority of shared code and then a mono repo for each full-stack application (api+web+cdk). There are other packages published by the commons package that show up just fine, but for whatever reason one of them is missing despite it being in dependencies section of root package json. |
Alright well I didn’t have to use a custom executor, all my deps are working now. I’m guessing at one point the problematic dependencies were a devDependency in my root package.json and the project graph didn’t want to detect that.
Would be curious if this helps anyone else assuming you’re on latest nx and using the correct executors. It’s working for me with |
I face same issue. Anyone has solution for this issue?. so for now, I must copy root package.json for each project to handle missing modules |
It happened to me and I found out that the missing module is not added to the root package.json. I cleaned the node_modules and reinstall all the dependencies and it's working now. |
Hi all, the original scenario (about
If anyone runs into a similar issue, please share your reproduce steps. |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
any updates? |
@yasinntza I asked for a new reproduce to investigate further as the original issue seems to have been solved already. Check my previous message. Can you share a reproduce? |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
@nartc sorry; I haven't been actively developing a NX project lately and since have switched to Vite and Turborepo, however, may consider converting back to Nx as Turborepo docker builds are insanely slow when "pruning" dependencies. My NX project I have in production uses webpack plugins to create pruned package.json files, so it's great to see that this may work out of the box now. |
@nartc I can still reproduce this issue with OP's reproduction steps.
The output Report:
Can we remove Edit.Okay I have figured out what is causing this issue... It is related to I will post another issue |
@dan-cooke Thank you for the steps. However, your reproduction is against 13.10.6 which is an old version. Can you try the steps again with the latest 14.5.x? If it's still an issue with 14.5.x, then I'll remove the retry-with-latest label. |
@nartc As for OP's issue - I cannot actually reproduce, however ther are some things to note:
I believe this current issue can be closed however, as with OP's steps (As long as you import a named export) it cannot be reproduced |
Thanks for the clarifications.
As for this issue, I'll leave it open for a bit longer to see if anything comes up. Thanks again for your time |
I'm facing a similar issue. I generated a publishable lib that uses a MUI component but the generated Here is a repo with the minimal setup: What I'm missing? Update Finally solved it https://stackoverflow.com/questions/73293762/nx-missing-dependencies-on-generated-package-json/73306728#73306728 |
In case it helps anyone else, my solution to this issue was a bit different. The build executor is |
Thanks @svaterlaus that worked for me! |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
I'm trying to create a production Nest.js build with a minimal dependency tree. "generatePackageJson" does not include dependencies from a library within my own workspace.
Scenario:
apps/graphql
importslibs/config
.libs/config
importsdotenv
(3rd party).dotenv
is not included in thepackage.json
ofapps/graphql
generated file.Expected Behavior
I expect
dotenv
to be listed inpackage.json
.Steps to Reproduce
config
nest.js Library withimport { config } from 'dotenv';
config
library"generatePackageJson": true
option to app build target.dotenv
does not exist inpackage.json
Failure Logs
Environment
Extra Credit
Generated package.json should also either lock to exact package numbers or create a package.lock file. It's probably easier to just pin down exact package numbers:
"some-pkg": "1.2.3"
instead of"some-pkg": "^1.2.0"
The text was updated successfully, but these errors were encountered: