nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.75k stars 2.37k forks source link

package.json generated locally is sometimes ok, but never during build on github #28985

Open miszczu-drako opened 2 days ago

miszczu-drako commented 2 days ago

Current Behavior

I have a brand new nx workspace, a simple node application + express framework. The app is located is apps folder There are also 3 libs generated this way: npx nx generate @nx/node:library --name=my-app-api --directory=libs/my-app/api --importPath=@mtc/my-app-api --projectNameAndRootFormat=as-provided --strict=true --testEnvironment=node --no-interactive

When I run npx nx run my-app:build locally on my machine, the generated dist/apps/my-app/package.json file in most cases looks like this:

{
  "name": "my-app",
  "version": "0.0.1",
  "dependencies": {
    "express": "4.18.3",
    "pino": "9.5.0",
    "uuid": "11.0.3"
  },
  "main": "./main.js",
  "type": "commonjs"
}

Sometimes express dependency is missing

However when I run the same command in github action https://github.com/miszczu-drako/nx-issue/blob/main/.github/workflows/ci.yml line 39, the generated package.json looks like this in all cases:

{
  "name": "my-app",
  "version": "0.0.1",
  "main": "./main.js",
  "type": "commonjs"
}

Here's a sample of workflow run https://github.com/miszczu-drako/nx-issue/actions/runs/11902565506/job/33167834974

Expected Behavior

The generated package.json should have all dependencies listed

GitHub Repo

https://github.com/miszczu-drako/nx-issue

Steps to Reproduce

  1. just trigger a workflow on github and see the output of cat dist/apps/my-app/package.json

Nx Report

$ npx nx report

 NX   Report complete - copy this into the issue template

Node           : 22.11.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.9.0

nx                 : 20.1.2
@nx/js             : 20.1.2
@nx/jest           : 20.1.2
@nx/eslint         : 20.1.2
@nx/workspace      : 20.1.2
@nx/devkit         : 20.1.2
@nx/esbuild        : 20.1.2
@nx/eslint-plugin  : 20.1.2
@nx/node           : 20.1.2
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

Package Manager Version

No response

Operating System

Additional Information

I think that it broke around nx version 19.1