Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple issues with a brand new nest with angular project #22144

Open
1 of 4 tasks
robertIsaac opened this issue Mar 4, 2024 · 1 comment
Open
1 of 4 tasks

multiple issues with a brand new nest with angular project #22144

robertIsaac opened this issue Mar 4, 2024 · 1 comment
Assignees
Labels
scope: node Issues related to Node, Express, NestJS support for Nx type: bug

Comments

@robertIsaac
Copy link
Contributor

Current Behavior

right now when I create a new project using angular then add nest to do there are multiple problems

  1. the GitHub action fail by default with error fatal: ambiguous argument 'origin/main': unknown revision or path not in the working tree.
    that's because the branch that nx created is master but the default branch in nrwl/nx-set-shas jon is main
  2. I choose to playwright as my e2e it fails by default with error Executable doesn't exist at /home/runner/.cache/ms-playwright/chromium-1105/chrome-linux/chrome
  3. the nest e2e doesn't work out of the box in the CI because it needs the API to be served first, I wasn't sure how to actually make it work so I just deleted it 😅
  4. running nx run-many -t serve doesn't work, only the first one actually is served and it's random sometimes it's Angular and some other it's nest

Expected Behavior

  1. create the default branch main or add main-branch-name for master in the .github/workflows/ci.yml file like what I did here robertIsaac/ng-nest-reprod@527b401
  2. when choosing playwright as e2e, nx should by default add postinstall script npx playwright install --with-deps as I did in robertIsaac/ng-nest-reprod@a8b0207 or to add it as an extra step in the ci.yaml file
  3. it should work out of the box
  4. it should work for both angular and nest, this actually used to work in 17.x version, seems to be broken in 18.0 version

GitHub Repo

https://github.com/robertIsaac/ng-nest-reprod

Steps to Reproduce

1.create a new project npx create-nx-workspace ng-nest-reprod then follow these steps

 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

√ Which stack do you want to use? · angular
√ Integrated monorepo, or standalone project? · integrated
√ Application name · fe
√ Which bundler would you like to use? · esbuild
√ Default stylesheet format · scss
√ Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? · Yes
√ Test runner to use for end to end (E2E) tests · playwright
√ Do you want Nx Cloud to make your CI fast? · github
  1. run nx add @nx/nest
  2. run nx g @nx/nest:app be --frontendProject fe

Nx Report

Node   : 20.11.0
OS     : win32-x64
npm    : 10.4.0

nx                 : 18.0.7
@nx/js             : 18.0.7
@nx/jest           : 18.0.7
@nx/linter         : 18.0.7
@nx/eslint         : 18.0.7
@nx/workspace      : 18.0.7
@nx/angular        : 18.0.7
@nx/cypress        : 18.0.7
@nx/devkit         : 18.0.7
@nx/eslint-plugin  : 18.0.7
@nx/nest           : 18.0.7
@nx/node           : 18.0.7
@nx/playwright     : 18.0.7
@nrwl/tao          : 18.0.7
@nx/web            : 18.0.7
@nx/webpack        : 18.0.7
typescript         : 5.3.3

Failure Logs

nx s be

> nx run be:serve:development

Build option outputFileName not set for be. Using fallback value of dist\apps\be\main.js.

> nx run be:build

chunk (runtime: main) main.js (main) 2.71 KiB [entry] [rendered]
webpack compiled successfully (f60f6de829567d37)

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

 NX   Successfully ran target build for project be (3s)

Debugger listening on ws://localhost:9229/45b5e4be-970d-449c-ae66-4be0dfa0cf52
Debugger listening on ws://localhost:9229/45b5e4be-970d-449c-ae66-4be0dfa0cf52
For help, see: https://nodejs.org/en/docs/inspector

[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [NestFactory] Starting Nest application...
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [InstanceLoader] AppModule dependencies initialized +5ms
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [RoutesResolver] AppController {/api}: +12ms
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [RouterExplorer] Mapped {/api, GET} route +1ms
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [NestApplication] Nest application successfully started +1ms
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG 🚀 Application is running on: http://localhost:3000/api

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

these are 4 different issues related to multiple issues, if you want me to create separate issues for each or for one of them just tell me and I will do
I'm also open to contribute to fix these issues, just let's agree how they should work and point me to where to go to fix them because I get lost easily in the repo

@AgentEnder AgentEnder added the scope: node Issues related to Node, Express, NestJS support for Nx label Mar 5, 2024
@exocom
Copy link
Contributor

exocom commented Mar 7, 2024

@AgentEnder We have an empty node + NestJS and experienced number 3 above as well.

The reason for the failure is because the @nx/jest/plugin is creating a VIRTUAL test target on the e2e project.

2 possible solutions:

  1. Instead of 2 projects merge them into one with an e2e folder. (We've seen this in the wild.)
  2. Do not add the virtual task the e2e projects.

nx.json

    {
      "plugin": "@nx/jest/plugin",
      "options": {
        "targetName": "test"
      }
    }

Here is the output:

❌ > nx run gateway-e2e:test
  
  
  Setting up...
  
   FAIL   gateway-e2e  src/gateway/gateway.spec.ts
    GET /api
      ✕ should return a message (39 ms)
  
    ● GET /api › should return a message
  
      AggregateError
  
        at Function.Object.<anonymous>.AxiosError.from (../../node_modules/.pnpm/axios@1.6.7/node_modules/axios/lib/core/AxiosError.js:89:14)
        at RedirectableRequest.handleRequestError (../../node_modules/.pnpm/axios@1.6.7/node_modules/axios/lib/adapters/http.js:610:25)
        at ClientRequest.eventHandlers.<computed> (../../node_modules/.pnpm/follow-redirects@1.15.5/node_modules/follow-redirects/index.js:38:24)
        at Axios.request (../../node_modules/.pnpm/axios@1.6.7/node_modules/axios/lib/core/Axios.js:45:[41](https://github.com/safe-health/platform/actions/runs/8180154723/job/22367616715#step:8:46))
  
      Cause:
      AggregateError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: node Issues related to Node, Express, NestJS support for Nx type: bug
Projects
None yet
Development

No branches or pull requests

4 participants