nx icon indicating copy to clipboard operation
nx copied to clipboard

nx application is not opening nx run app-api:serve:development

Open shalendrasingh opened this issue 4 months ago • 15 comments

Current Behavior

Whenever I tried to serve the NX application I did not get any error or response.

this is what is shown in the terminal

 pnpm nx serve app-api

 >  NX   Running target serve for project app-api and 1 task it depends on:

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

> nx run app-api:generate-build-info

{
  buildVersion: 'ver-local-46c5838960869212f41cc902af4474587b030c02',
  buildAt: '2024-02-16T06:58:50.721Z'
}
Build info written to C:\Users\DELL\Desktop\New folder\app-pg\packages\app-api\build-info.json

> nx run app-api:serve:development

Expected Behavior

My expectation is application will run or throw some error

GitHub Repo

No response

Steps to Reproduce

just run pnpm nx serve app-api

Nx Report

Whenever I tried to serve the NX application I did not get any error or response.

this is what is shown in the terminal

 pnpm nx serve app-api

 >  NX   Running target serve for project app-api and 1 task it depends on:

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

> nx run app-api:generate-build-info

{
  buildVersion: 'ver-local-46c5838960869212f41cc902af4474587b030c02',
  buildAt: '2024-02-16T06:58:50.721Z'
}
Build info written to C:\Users\DELL\Desktop\New folder\app-pg\packages\app-api\build-info.json

> nx run app-api:serve:development


### Failure Logs

_No response_

### Package Manager Version

_No response_

### Operating System

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

### Additional Information

_No response_

shalendrasingh avatar Feb 16 '24 07:02 shalendrasingh

Hey, can you provide the output of nx report as well as the output of nx show project app-api? If possible the a reproduction repo showing the issue would be helpful as well.

AgentEnder avatar Feb 16 '24 20:02 AgentEnder

@AgentEnder

I am also seeing this behaviour, and was able to reproduce it like this:

Create a new workspace

npx create-nx-workspace@latest --preset angular-standalone --bundler esbuild --style css --ssr false --ci skip --e2eTestRunner none issue-21838
cd issue-21838

Modify project.json to add a dependency:

  "targets": {
    "some-task": {
      "command": "npx -y cowsay Moo"
    },
  ...
    "build": {
      "dependsOn": ["some-task"],
    ...

Run a build

nx build
❯ nx build

> nx run issue-21838:some-task

 _____
< Moo >
 -----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

> nx run issue-21838:build:production

The command will hang, never complete and not respond to Ctrl-C. It needs to be manually killed in the task manager.

image

❯ nx report

 >  NX   Report complete - copy this into the issue template

   Node   : 20.10.0
   OS     : win32-x64
   npm    : 10.3.0

   nx (global)        : 18.0.4
   nx                 : 18.0.4
   @nx/js             : 18.0.4
   @nx/jest           : 18.0.4
   @nx/linter         : 18.0.4
   @nx/eslint         : 18.0.4
   @nx/workspace      : 18.0.4
   @nx/angular        : 18.0.4
   @nx/cypress        : 18.0.4
   @nx/devkit         : 18.0.4
   @nx/eslint-plugin  : 18.0.4
   @nrwl/tao          : 18.0.4
   @nx/web            : 18.0.4
   @nx/webpack        : 18.0.4
   typescript         : 5.3.3
❯ nx show project issue-21838
{"root":".","includedScripts":[],"name":"issue-21838","targets":{"lint":{"cache":true,"inputs":["default","{workspaceRoot}/.eslintrc.json","{workspaceRoot}/tools/eslint-rules/**/*",{"externalDependencies":["eslint"]}],"executor":"nx:run-commands","options":{"cwd":".","command":"eslint ./src"},"configurations":{}},"test":{"options":{"cwd":".","command":"jest"},"cache":true,"inputs":["default","^production",{"externalDependencies":["jest"]}],"outputs":["{projectRoot}\\coverage\\issue-21838"],"executor":"nx:run-commands","configurations":{}},"build":{"executor":"@angular-devkit/build-angular:application","cache":true,"dependsOn":["some-task"],"inputs":["production","^production"],"outputs":["{options.outputPath}"],"options":{"outputPath":"dist/issue-21838","index":"./src/index.html","browser":"./src/main.ts","polyfills":["zone.js"],"tsConfig":"./tsconfig.app.json","assets":["./src/favicon.ico","./src/assets"],"styles":["./src/styles.css"],"scripts":[]},"configurations":{"production":{"budgets":[{"type":"initial","maximumWarning":"500kb","maximumError":"1mb"},{"type":"anyComponentStyle","maximumWarning":"2kb","maximumError":"4kb"}],"outputHashing":"all"},"development":{"optimization":false,"extractLicenses":false,"sourceMap":true}},"defaultConfiguration":"production"},"some-task":{"executor":"nx:run-commands","options":{"command":"npx -y cowsay Moo"},"configurations":{}},"serve":{"dependsOn":["some-task"],"executor":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"issue-21838:build:production"},"development":{"buildTarget":"issue-21838:build:development"}},"defaultConfiguration":"development","options":{}},"extract-i18n":{"executor":"@angular-devkit/build-angular:extract-i18n","options":{"buildTarget":"issue-21838:build"},"configurations":{}}},"sourceRoot":"./src","projectType":"application","$schema":"node_modules/nx/schemas/project-schema.json","prefix":"issue-21838","tags":[],"implicitDependencies":[]}

Removing the dependsOn fixes the build. A script in package.json can produce the same behaviour as a workaround.

Ionaru avatar Feb 17 '24 17:02 Ionaru

Probably related to https://github.com/nrwl/nx/issues/21744 and https://github.com/nrwl/nx/issues/21779

Ionaru avatar Feb 17 '24 17:02 Ionaru

Looks like setting the environment variable NX_NATIVE_COMMAND_RUNNER=false can also work as a workaround.

Ionaru avatar Feb 17 '24 17:02 Ionaru

I have the same issue after upgrading from 17.2.8 to 18.0.4.

Looks like setting the environment variable NX_NATIVE_COMMAND_RUNNER=false can also work as a workaround.

This didn't help in my case.

Hey, can you provide the output of nx report as well as the output of nx show project app-api? If possible the a reproduction repo showing the issue would be helpful as well.

My nx report

   Node   : 21.6.2
   OS     : darwin-arm64
   npm    : 10.4.0
   
   nx                 : 18.0.4
   @nx/js             : 18.0.4
   @nx/linter         : 18.0.4
   @nx/eslint         : 18.0.4
   @nx/workspace      : 18.0.4
   @nx/cypress        : 18.0.4
   @nx/devkit         : 18.0.4
   @nx/eslint-plugin  : 18.0.4
   @nx/react          : 18.0.4
   @nrwl/tao          : 18.0.4
   @nx/vite           : 18.0.4
   @nx/web            : 18.0.4
   typescript         : 5.3.3

My nx show project

{
  "root": ".",
  "name": "frontend",
  "targets": {
    "start": {
      "executor": "nx:run-script",
      "options": { "script": "start" },
      "configurations": {}
    },
    "build": {
      "executor": "@nx/vite:build",
      "dependsOn": ["^build"],
      "inputs": ["production", "^production"],
      "outputs": ["{options.outputPath}"],
      "defaultConfiguration": "production",
      "options": { "outputPath": "dist/frontend" },
      "configurations": {
        "development": { "mode": "development" },
        "production": { "mode": "production" }
      }
    },
    "test": {
      "executor": "@nx/vite:test",
      "inputs": ["default", "^production"],
      "outputs": ["{projectRoot}/coverage/frontend"],
      "options": {
        "passWithNoTests": true,
        "reportsDirectory": "coverage/frontend"
      },
      "configurations": {}
    },
    "lint": {
      "executor": "@nx/eslint:lint",
      "inputs": [
        "default",
        "{workspaceRoot}/.eslintrc.json",
        "{workspaceRoot}/.eslintignore"
      ],
      "cache": true,
      "options": { "lintFilePatterns": ["./src/**/*.{ts,tsx,js,jsx}"] },
      "configurations": {}
    },
    "serve": {
      "executor": "@nx/vite:dev-server",
      "defaultConfiguration": "development",
      "options": { "buildTarget": "frontend:build" },
      "configurations": {
        "development": {
          "buildTarget": "frontend:build:development",
          "hmr": true
        },
        "production": {
          "buildTarget": "frontend:build:production",
          "hmr": false
        }
      }
    },
    "preview": {
      "executor": "@nx/vite:preview-server",
      "defaultConfiguration": "development",
      "options": { "buildTarget": "frontend:build" },
      "configurations": {
        "development": { "buildTarget": "frontend:build:development" },
        "production": { "buildTarget": "frontend:build:production" }
      }
    }
  },
  "$schema": "node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "./src",
  "projectType": "application",
  "tags": [],
  "implicitDependencies": []
}

My project is a pretty simple Vite, React and TypeScript Project - so it is probably also easy to reproduce.

CMiksche avatar Feb 19 '24 18:02 CMiksche

Having the same problem on Windows 10 going from Nx v17.2.8 to v18.0.4 with dependsOn.

  • If there are two items in the dependsOn array it gets stuck on the 2nd one.
  • If there is one item in the dependsOn array it gets stuck on the target trying to be run.
  • With an empty dependsOn array, the target runs fine.

So it seems like it can only run one thing before it just hangs where Ctrl+C doesn't even work.

In my case, setting NX_NATIVE_COMMAND_RUNNER=false did make things work so that was good. Not sure what that setting does though.

rob4226 avatar Feb 22 '24 11:02 rob4226

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Mar 08 '24 00:03 github-actions[bot]

Replying so it stays active... many people seem to have this issue.

CMiksche avatar Mar 08 '24 07:03 CMiksche

Probably related: #21965, #21978, #21779, #21744, #22094

rob4226 avatar Mar 09 '24 07:03 rob4226

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Mar 24 '24 00:03 github-actions[bot]

Not stale

Lonli-Lokli avatar Mar 24 '24 00:03 Lonli-Lokli

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Apr 09 '24 00:04 github-actions[bot]

Having the same problem on Windows 10 going from Nx v17.2.8 to v18.0.4 with dependsOn.

  • If there are two items in the dependsOn array it gets stuck on the 2nd one.
  • If there is one item in the dependsOn array it gets stuck on the target trying to be run.
  • With an empty dependsOn array, the target runs fine.

So it seems like it can only run one thing before it just hangs where Ctrl+C doesn't even work.

In my case, setting NX_NATIVE_COMMAND_RUNNER=false did make things work so that was good. Not sure what that setting does though.

This issue still persist. And this fix worked for me. Anybody knows what this NX_NATIVE_COMMAND_RUNNER var does?

shehan-mark avatar Apr 18 '24 11:04 shehan-mark

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar May 03 '24 00:05 github-actions[bot]

Just ran into it, so not stale.

rubenprins avatar May 03 '24 09:05 rubenprins