nx icon indicating copy to clipboard operation
nx copied to clipboard

GeneratePackgageJson : true Doesn't have any package in package.json

Open QQbit opened this issue 1 year ago โ€ข 1 comments

Current Behavior

Building with option generatePackageJson: true in project.json produces a package.json file is not have anything.

{
  "name": "backend",
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "apps/backend/src",
  "projectType": "application",
  "targets": {
    "build": {
      "executor": "@nx/esbuild:esbuild",
      "outputs": ["{options.outputPath}"],
      "defaultConfiguration": "production",
      "options": {
        "platform": "node",
        "outputPath": "dist/apps/backend",
        "format": ["cjs"],
        "bundle": false,
        "main": "apps/backend/src/main.ts",
        "tsConfig": "apps/backend/tsconfig.app.json",
        "generatePackageJson": true,
        "esbuildOptions": {
          "sourcemap": true,
          "outExtension": {
            ".js": ".js"
          }
        }
      },
      "configurations": {
        "development": {},
        "production": {
          "esbuildOptions": {
            "sourcemap": false,
            "outExtension": {
              ".js": ".js"
            }
          }
        }
      }
    },
    "serve": {
      "executor": "@nx/js:node",
      "defaultConfiguration": "development",
      "options": {
        "buildTarget": "backend:build"
      },
      "configurations": {
        "development": {
          "buildTarget": "backend:build:development"
        },
        "production": {
          "buildTarget": "backend:build:production"
        }
      }
    },
    "lint": {
      "executor": "@nx/linter:eslint",
      "outputs": ["{options.outputFile}"],
      "options": {
        "lintFilePatterns": ["apps/backend/**/*.ts"]
      }
    },
    "test": {
      "executor": "@nx/jest:jest",
      "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
      "options": {
        "jestConfig": "apps/backend/jest.config.ts",
        "passWithNoTests": true
      },
      "configurations": {
        "ci": {
          "ci": true,
          "codeCoverage": true
        }
      }
    },
    "docker-build": {
      "dependsOn": ["build"],
      "command": "docker build -f apps/backend/Dockerfile . -t backend"
    }
  },
  "tags": []
}

after build my app the generated package.json is following:

{
  "name": "backend",
  "version": "0.0.1",
  "main": "./main.js"
}

Now I can't startup the app in my docker container is not found module because the package no have anythings.

Expected Behavior

package should be included in the generated package json

GitHub Repo

No response

Steps to Reproduce

  1. pnpm backend:build

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 20.11.1
   OS     : darwin arm64
   pnpm   : 9.4.0
   Hasher : Native
   
   nx                 : 16.3.2
   @nx/js             : 16.3.2
   @nx/jest           : 16.3.2
   @nx/linter         : 16.3.2
   @nx/workspace      : 16.3.2
   @nx/cypress        : 16.3.2
   @nx/devkit         : 16.3.2
   @nx/esbuild        : 16.3.2
   @nx/eslint-plugin  : 16.3.2
   @nx/next           : 16.3.2
   @nx/node           : 16.3.2
   @nx/react          : 16.3.2
   @nrwl/tao          : 16.3.2
   @nx/vite           : 16.3.2
   @nx/web            : 16.3.2
   typescript         : 5.0.2
   ---------------------------------------
   Community plugins:
   @nx/eslint  : 17.1.3
   nx-electron : 17.0.1

Failure Logs

No response

Package Manager Version

pnpm 9.4.0

Operating System

  • [X] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

No response

QQbit avatar Jun 28 '24 04:06 QQbit

Can you create a small repro, This is working for me.

ndcunningham avatar Jun 28 '24 16:06 ndcunningham

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Jul 06 '24 00:07 github-actions[bot]

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Jul 16 '24 00:07 github-actions[bot]

Same issue when upgrading from 19.0.4 to 19.5.3 with pnpm 8.15.7 and node 20.10.0

Suddenly no dependencies listed in the generated package.json for any of my apps

Nick-Lucas avatar Jul 27 '24 16:07 Nick-Lucas

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Aug 05 '24 00:08 github-actions[bot]

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[bot] avatar Sep 27 '24 00:09 github-actions[bot]