question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

19reactions
viktornordcommented, Sep 20, 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!

9reactions
husny-ahamed-mgcommented, Aug 23, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

package.json - npm Docs
This document is all you need to know about what's required in your package.json file. It must be actual JSON, not just a...
Read more >
How to package a node app with their dependencies
Each node app has a package.json in which it specifies its dependencies, later installed inside the node_modules folder.
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
How do I add comments to package.json for npm install?
It lets you put your NPM scripts into a separate JavaScript file, where you can add comments galore and any other JavaScript logic...
Read more >
Common NPM Mistakes Every Developer Should Avoid
json with a property named files . with files property, you can easily specify files or directories you need to publish. { “name”:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found