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

nx generate @nx/next:application dry-run fails when @nx/playwright is not yet installed as a dependency #30184

Open
1 of 4 tasks
zzeni opened this issue Feb 26, 2025 · 0 comments · May be fixed by #30185
Open
1 of 4 tasks

Comments

@zzeni
Copy link

zzeni commented Feb 26, 2025

Current Behavior

The nx-console generator for next applications has playwright as the default option for e2eTestRunner. However the dry-run output would always show an error if @nx/playwright is not yet a part of the project dependencies and hence the actual output stays obscured.
The only way to pass it and see the actual dry-run output is to either install @nx/playwright or explicitly set e2eTestRunner to something else or none.

🀫 yarn nx generate @nx/next:application --directory=apps/test-app --name=test-app --no-interactive --dry-run 

 NX  Generating @nx/next:application

 NX   NOTE: This generator does not support --dry-run. If you are running this in Nx Console, it should execute fine once you hit the "Generate" button.

🀫 yarn nx generate @nx/next:application --directory=apps/test-app --name=test-app --no-interactive --e2eTestRunner=cypress --dry-run 

 NX  Generating @nx/next:application

UPDATE nx.json
UPDATE .gitignore
CREATE apps/test-app/index.d.ts
CREATE apps/test-app/next-env.d.ts
CREATE apps/test-app/next.config.js
CREATE apps/test-app/public/.gitkeep
CREATE apps/test-app/public/favicon.ico
CREATE apps/test-app/tsconfig.json
CREATE apps/test-app/src/app/api/hello/route.ts
CREATE apps/test-app/src/app/global.css
CREATE apps/test-app/src/app/page.tsx
CREATE apps/test-app/src/app/layout.tsx
CREATE apps/test-app/src/app/registry.tsx
CREATE apps/test-app/project.json
CREATE apps/test-app-e2e/project.json
CREATE apps/test-app-e2e/src/e2e/app.cy.ts
CREATE apps/test-app-e2e/src/support/app.po.ts
CREATE apps/test-app-e2e/src/support/e2e.ts
CREATE apps/test-app-e2e/src/fixtures/example.json
CREATE apps/test-app-e2e/src/support/commands.ts
CREATE apps/test-app-e2e/cypress.config.ts
CREATE apps/test-app-e2e/tsconfig.json
CREATE apps/test-app-e2e/.eslintrc.json
CREATE apps/test-app/.eslintrc.json
UPDATE package.json

NOTE: The "dryRun" flag means no changes were made.

Expected Behavior

I would expect the actual dry-run output to be shown, along with a warning that @nx/playwright would be installed once the "Generate" button is hit. E.g.:

 NX  Generating @nx/next:application

NOTE: We've found a missing dependency for this configuration: @nx/playwright, which shall be installed once you run `nx generate` without the "dryRun" flag (or once you hit the "Generate" button if you are running this in Nx Console)

UPDATE nx.json
UPDATE .gitignore
CREATE apps/one-portal/index.d.ts
CREATE apps/one-portal/next-env.d.ts
CREATE apps/one-portal/next.config.js
CREATE apps/one-portal/public/.gitkeep
CREATE apps/one-portal/public/favicon.ico
CREATE apps/one-portal/specs/index.spec.tsx
CREATE apps/one-portal/tsconfig.json
CREATE apps/one-portal/src/app/api/hello/route.ts
CREATE apps/one-portal/src/app/global.css
CREATE apps/one-portal/src/app/page.tsx
CREATE apps/one-portal/src/app/layout.tsx
CREATE apps/one-portal/project.json
CREATE apps/one-portal-e2e/project.json
CREATE apps/one-portal/jest.config.ts
CREATE apps/one-portal/tsconfig.spec.json
CREATE apps/one-portal/.eslintrc.json
CREATE apps/one-portal/postcss.config.js
CREATE apps/one-portal/tailwind.config.js

NOTE: The "dryRun" flag means no changes were made.

GitHub Repo

No response

Steps to Reproduce

  1. setup a monorepo project with nx:

     🀫 npx create-nx-workspace
     Need to install the following packages:
     [email protected]
     Ok to proceed? (y) 
    
     NX   Let's create a new workspace [https://nx.dev/getting-started/intro]
    
     ✔ Where would you like to create your workspace? · test-org
     ✔ Which stack do you want to use? · none
     ✔ Would you like to use Prettier for code formatting? · No
     ✔ Which CI provider would you like to use? · skip
     ✔ Would you like remote caching to make your build faster? · skip
    
     NX   Creating your v20.4.6 workspace.
    
     ✔ Installing dependencies with npm
     ✔ Successfully created the workspace: test-org.
    
     NX   Welcome to the Nx community! 👋
    
     🌟 Star Nx on GitHub: https://github.com/nrwl/nx
     📢 Stay up to date on X: https://x.com/nxdevtools
     💬 Discuss Nx on Discord: https://go.nx.dev/community
    
     🀫 cd test-org/ && yarn install
     ➤ YN0000: Done with warnings in 32s 929ms
    
  2. Add @nx/next

     🀫 yarn add "@nx/next"
     ➤ YN0000: Done with warnings in 28s 916ms
  3. Try to generate a next application

     🀫 yarn nx generate @nx/next:application --directory=test-app --name=test-app --no-interactive --dry-run --verbose
    
     NX  Generating @nx/next:application
    
    
     NX   NOTE: This generator does not support --dry-run. If you are running this in Nx Console, it should execute fine once you hit the "Generate" button.
    
    
     Error: NOTE: This generator does not support --dry-run. If you are running this in Nx Console, it should execute fine once you hit the "Generate" button.

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.12.2
OS             : darwin-arm64
Native Target  : aarch64-macos
yarn           : 3.8.2

nx          : 20.4.6
@nx/js      : 20.4.6
@nx/next    : 20.4.6
typescript  : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript

Failure Logs

Error: NOTE: This generator does not support --dry-run. If you are running this in Nx Console, it should execute fine once you hit the "Generate" button.

        at ensurePackage (/Users/air/Projects/contrib/test-org/.yarn/__virtual__/@nx-devkit-virtual-50998d8de1/0/cache/@nx-devkit-npm-20.4.6-9b37a3221f-e43960f736.zip/node_modules/@nx/devkit/src/utils/package-json.js:293:15)
        at addE2e (/Users/air/Projects/contrib/test-org/.yarn/__virtual__/@nx-next-virtual-ac8a4f4981/0/cache/@nx-next-npm-20.4.6-d2fac357b8-f3b91ed6b8.zip/node_modules/@nx/next/src/generators/application/lib/add-e2e.js:83:71)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async applicationGeneratorInternal (/Users/air/Projects/contrib/test-org/.yarn/__virtual__/@nx-next-virtual-ac8a4f4981/0/cache/@nx-next-npm-20.4.6-d2fac357b8-f3b91ed6b8.zip/node_modules/@nx/next/src/generators/application/application.js:54:21)
        at async /Users/air/Projects/contrib/test-org/.yarn/unplugged/nx-virtual-818b65d426/node_modules/nx/src/command-line/generate/generate.js:240:26
        at async handleErrors (/Users/air/Projects/contrib/test-org/.yarn/unplugged/nx-virtual-818b65d426/node_modules/nx/src/utils/handle-errors.js:8:24)
        at async Object.handler (/Users/air/Projects/contrib/test-org/.yarn/unplugged/nx-virtual-818b65d426/node_modules/nx/src/command-line/generate/command-object.js:13:22)

Package Manager Version

No response

Operating System

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

Additional Information

I shall be able to fix the issue and create a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant