package.json per app

See original GitHub issue

First 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:open
  • Created 4 years ago
  • Reactions:469
  • Comments:175 (14 by maintainers)

github_iconTop GitHub Comments

114reactions
vsavkincommented, Sep 2, 2019

Thanks for submitting the issue.

You could create a package.json per project, and for instance use something like yarn workspaces to 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.

83reactions
the-ultcommented, Sep 3, 2019

Thanks @vsavkin

We love the ONE package.json to rule them all approach and rather have one package.json instead of multiple.

The only reason why we have a separate package.json for our Express (GraphQL-server) app is that we need a small production node_modules for 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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nrwl Nx and monorepo - handle package.json for particular ...
Generates a package.json file with the project's node_module dependencies populated for installing in a container. If a package.json exists ...
Read more >
Project Configuration
Projects can be configured in package.json (if you use npm scripts and ... Both package.json and project.json files are located in each project's...
Read more >
package.json
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 >
What Is package.json?
Your project's package.json is the central place to configure and describe how to interact with and run your application. It is used by...
Read more >
nrwl-nx/community - Gitter
Does nx affected apps not work with lazy loaded modules ? ... 1) Can I have a package.json file for each app/service/library, if...
Read more >

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