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.

generatePackageJson on nx 15 generates the the dependencies and versions differently than 14

See original GitHub issue

Current Behavior

npm ci of a a copied apps dist directory breaks after update to nx 15 because the root package-lock.json dependency version does not match the generated package.json dependency version.

With nx 14 when using the "executor": "@nrwl/node:webpack", with "generatePackageJson": true the version of the dependency in the generated package.json matched the root package.json including the range.

With nx 15 and the same config the the generated package.json dependency appears to be the evaluated exact version without the range.

before nx 15

{
  "scripts": {
    "start": "node main.js",
    "release": "semantic-release-plus"
  },
  "dependencies": {
    "axios": "^0.26.0",
    "dayjs": "^1.10.7",
    "jsonc-parser": "^3.0.0",
    "nodemailer": "^6.7.2",
    "qs": "^6.10.3",
    "tslib": "^2.0.0"
  },
  "main": "main.js"
}

after nx 15 update

{
  "scripts": {
    "start": "node main.js",
    "release": "semantic-release-plus"
  },
  "dependencies": {
    "axios": "0.26.1",
    "call-bind": "1.0.2",
    "dayjs": "1.11.5",
    "follow-redirects": "1.15.2",
    "function-bind": "1.1.1",
    "get-intrinsic": "1.1.3",
    "has": "1.0.3",
    "has-symbols": "1.0.3",
    "jsonc-parser": "3.2.0",
    "nodemailer": "6.8.0",
    "object-inspect": "1.12.2",
    "qs": "6.11.0",
    "side-channel": "1.0.4",
    "tslib": "2.4.0"
  },
  "main": "main.js"
}

Expected Behavior

the versions in the generated package.json should be exactly the same including range of the root package.json

Steps to Reproduce

Working Branch using nx 14 - https://github.com/JoA-MoS/garage/

Bad branch PR using nx 15 - https://github.com/JoA-MoS/garage/pull/81

Run build on both and compare generated package.json

nx build campsite-watcher
nx docker-build campsite-watcher

Failure Logs

Environment

>  NX   Report complete - copy this into the issue template

   Node : 16.18.0
   OS   : darwin x64
   npm  : 8.19.2
   
   nx : 15.0.0
   @nrwl/angular : 15.0.0
   @nrwl/cypress : 15.0.0
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.0.0
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.0.0
   @nrwl/expo : Not Found
   @nrwl/express : 15.0.0
   @nrwl/jest : 15.0.0
   @nrwl/js : 15.0.0
   @nrwl/linter : 15.0.0
   @nrwl/nest : 15.0.0
   @nrwl/next : Not Found
   @nrwl/node : 15.0.0
   @nrwl/nx-cloud : 14.7.0
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.0.0
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.0.0
   @nrwl/schematics : Not Found
   @nrwl/storybook : 15.0.0
   @nrwl/web : 15.0.0
   @nrwl/webpack : 15.0.0
   @nrwl/workspace : 15.0.0
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
         @semantic-release-plus/nx-tools: 1.0.0-alpha.6
         @storybook/angular: 6.5.12

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:17
  • Comments:70 (37 by maintainers)

github_iconTop GitHub Comments

7reactions
capJavertcommented, Oct 26, 2022

@FrozenPandaz @meeroslav is this something that is gonna be fixed/reverted to the 14.x behaviour or are you keeping it? I just think we all need some feedback because currently there is no valid solution to this. Thanks!

If I am looking at it correctly this change in behaviour was made in https://github.com/nrwl/nx/pull/12185

5reactions
leoncommented, Oct 24, 2022

Any news on this?

After updating to nx 15 all my express apps using generatePackageJson: true now contain a whole bunch of dependencies which where not getting added when using v14

When comparing the old output and the new, It looks like v15 is including all the peer dependencies as top level dependencies instead.

So I’m getting a lot of:

"@firebase/analytics": "0.8.3",
    "@firebase/analytics-compat": "0.1.16",
    "@firebase/analytics-types": "0.7.0",
    "@firebase/app": "0.8.2",
    "@firebase/app-check": "0.5.15",
    "@firebase/app-check-compat": "0.2.15",
    "@firebase/app-check-interop-types": "0.1.0",
    "@firebase/app-check-types": "0.4.0",
    "@firebase/app-compat": "0.1.37",
    "@firebase/app-types": "0.8.0",
    "@firebase/auth": "0.20.10",
    "@firebase/auth-compat": "0.2.23",
    "@firebase/auth-interop-types": "0.1.6",
    "@firebase/auth-types": "0.11.0",
    "@firebase/component": "0.5.20",
    "@firebase/database": "0.13.9",
    "@firebase/database-compat": "0.2.9",
    "@firebase/database-types": "0.9.16",
    "@firebase/firestore": "3.7.1",
    "@firebase/firestore-compat": "0.2.1",
    "@firebase/firestore-types": "2.5.0",
    "@firebase/functions": "0.8.7",
    "@firebase/functions-compat": "0.2.7",
    "@firebase/functions-types": "0.5.0",
    "@firebase/installations": "0.5.15",
    "@firebase/installations-compat": "0.1.15",
    "@firebase/installations-types": "0.4.0",
Read more comments on GitHub >

github_iconTop Results From Across the Web

Generate package.json on nx build / deployment
This will generate you package.json with the necessary dependencies for your app. Here example: "node-api": { "root": "apps/node ...
Read more >
What's new in Nx 15?. Nx v15 is finally here! Let's go… - Nx Blog
Meaning they have their own package.json with dependencies declared. To share and link packages locally within the monorepo, the "workspaces" feature from NPM/ ......
Read more >
Project Configuration - Nx
Nx merges the two files to get each project's configuration. The following configuration creates build and test targets for Nx. package.json project.json.
Read more >
generate-package-json-webpack-plugin - Yarn
Generates a package.json file containing the external modules used by your ... For limiting the dependencies inside package.json to only those that are ......
Read more >
nrwl-nx/community - Gitter
Hello, is there any way to generate package.json per app? ... I'm noticing that generating a library is specifying angular common and core...
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 Reddit Thread

No results found

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