Skip to content
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

feedback - can every app/lib have their own package.json? #3023

Closed
wizardnet972 opened this issue May 16, 2020 · 11 comments
Closed

feedback - can every app/lib have their own package.json? #3023

wizardnet972 opened this issue May 16, 2020 · 11 comments

Comments

@wizardnet972
Copy link
Contributor

wizardnet972 commented May 16, 2020

This is a feedback. I using nx and it works very well to my clients :)

One thing though, currently I have one package.json with many dependencies of my apps and libs and its hard to tell which dependency in use in which apps/libs.

It will be great if each app and lib will have its own package.json with the packages that app/lib uses.

Even all dependencies are the same versions, I want to know in ease what packages I use for the app.

Why? sometimes I want to move the apps from repo to another repo and I need to take the package.json and copy and filter the packages that the app/lib not use.

(In lerna monorepos for example I have each package the package.json`)

NX Team, what do you think about it? this can be done in nx?

@FrozenPandaz
Copy link
Collaborator

Yes, you can have multiple package.json for each app and lib but it will not be generated by default.

We strongly recommend using a single package.json in the root of the repo but you can setup your repo differently if you so wish. Nx should still work.

@zyf0330
Copy link
Contributor

zyf0330 commented Aug 17, 2021

Yes, you can have multiple package.json for each app and lib but it will not be generated by default.

We strongly recommend using a single package.json in the root of the repo but you can setup your repo differently if you so wish. Nx should still work.

I need per app package.json is for solving some problems.

  1. every app can publish itself, and record version in package.json.
  2. when build every app individually to docker image, npm can just install itself's dependencies according to package.json.

@zyf0330
Copy link
Contributor

zyf0330 commented Aug 17, 2021

Find something related to at #1777

@cntran
Copy link

cntran commented Oct 3, 2021

Yes, you can have multiple package.json for each app and lib but it will not be generated by default.

We strongly recommend using a single package.json in the root of the repo but you can setup your repo differently if you so wish. Nx should still work.

Hi there how would you configure this so each application can have a package.json in the monorepo setup? I need this in order to configure integration with an existing CI/CD pipeline that performs the build off changes to the Repo on a project.

@husny-ahamed-mg
Copy link

Yes, you can have multiple package.json for each app and lib but it will not be generated by default.

We strongly recommend using a single package.json in the root of the repo but you can setup your repo differently if you so wish. Nx should still work.

Some of us do not find it a good idea to use a single package.json for all the apps sorry. Could you please help us with some instructions on how to maintain separate package.json for separate apps.

@viktornord
Copy link

viktornord commented Sep 16, 2022

@FrozenPandaz
Having single package.json is error prone. Let me explain why:

  • in microservices world every service is supposed to be independent and isolated and having a single package.json already violates this
  • during the build process all dependencies are packaged within each and every build unless you configure webpack with tree shaking which you are forced to do in order to reduce the building time and build size
  • separate apps (microservices) are supposed to be maintained by different teams and having a single package.json forces all teams to migrate to new version of the lib / framework at the same time instead of being able to plan migration when they decide according to their workload
  • when you migrate to the new major version of a certain lib you can't deploy your microservice independently which is one of the main benefits of the microservices, since the breaking change is brought to all your apps and you are forced to migrate all of them which slows down the delivery

Given that I may understand some people may still want to have single package.json for simplicity but IMO this breaks flexibility and separation of concerns. I don't see any valid point in forcing people to use single package.json as the main approach in their projects.

Please give us an option to be able to separate the package.json per app and still benefit of all the nx features.

Thank you!

@towry
Copy link

towry commented Nov 3, 2022

@FrozenPandaz Any updates??

@alxpsr
Copy link

alxpsr commented Nov 8, 2022

@viktornord makes sense

@amivag
Copy link

amivag commented Mar 8, 2023

I've gone with the recommended method of putting a single package.json for all my apps/libs. However I don't feel comfortable not knowing which packages each app is relying upon. Is there a way to figure that out, if I ever decided to move an app into a different standalone project?
(and a side-question: how about git repositories? single one for all, or per-app?)

@neg3ntropy
Copy link

Enforcing a single version is not the same thing as providing the same dependency set to everything.
Maven has the concept of a BOM - Bill Of Materials - where you control just the version selection and I think it's a good feature, that could apply here.

I am looking at multi-module monorepos to avoid depending on anything framework related in core components, which can be packaged in different apps.

@github-actions
Copy link

github-actions bot commented May 7, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants