package.json per app
See original GitHub issueFirst of all,. just like to say thank you! I love nrwl nx and how well organized the code looks like when using nx! Also, it’s awesome you folks are investing in React!
Prerequisites
Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
- I am running the latest version
- I checked the documentation and found no answer
- I checked to make sure that this issue has not already been filed
- I’m reporting the issue to the correct repository (not related to Angular, AngularCLI or any dependency)
Expected Behavior
Is there a way we could have a package.json per app? If you are using docker, and would like, let’s say, have an angular app running in one container, and the nest api into another container, then both containers will have to run npm install over the all the npm packages even when angular packages are only a subset of all the packages (and viceversa with nest). Additionally, if we do npm install inside the containers, huge packages like cypress will be downloaded, even if they have nothing to do with the api (nest) build. This take its toll especially when running a CI build in travis, circleci, etc (yeah, I know there is cache, but it’s not 100% reliable).
Please describe the behavior you are expecting:
Would love to see every app having different package.json. Plus I think it is cleaner. Why having one package,json to rule them all? Seems very tightly coupled.
Current Behavior
What is the current behavior? There is only one package.json for all apps using nx
Failure Information (for bugs)
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
Context
Please provide any relevant information about your setup:
- version of Nx used: 8.4.13
Issue Analytics
- State:
- Created 4 years ago
- Reactions:469
- Comments:175 (14 by maintainers)
Top Related StackOverflow Question
Thanks for submitting the issue.
You could create a package.json per project, and for instance use something like
yarn workspacesto make npm installs relatively fast. We used to do it for one of our internal projects.We believe in the single-version policy, where, for instance, all applications using NestJS, use the same version of NestJS. Even though it looks a bit crazy at first, we think it is beneficial. Companies like Google do it. So having one node_modules at the root is very similar to what Google does (with a single
third_party).I’ll try to find sometime this week to author a guide on single-version policy, where I’ll also cover how to add multiple package.json files if you decide that single-version policy doesn’t work for you.
Thanks @vsavkin
We love the ONE
package.jsonto rule them all approach and rather have onepackage.jsoninstead of multiple.The only reason why we have a separate
package.jsonfor our Express (GraphQL-server) app is that we need a small productionnode_modulesfor the graphql-server, without all angular dependencies etc.Would be great if that could be part of the guide.
(each app lives in it’s own docker container)