qwikifiers / qwik-nx

Nx plugin for Qwik
131 stars 24 forks source link

creating new nx workspace with preset=qwik-nx using pnpx throws an error #44

Closed shairez closed 1 year ago

shairez commented 1 year ago

Describe the bug

Creating a new workspace with the qwik-nx preset throws (I'm using windows 10)

To Reproduce

Run pnpx create-nx-workspace --preset qwik-nx

Expected behavior To complete with no errors

Screenshots

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: spawn pnpm ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn pnpm',
  path: 'pnpm',
  spawnargs: [
    'exec',
    'nx',
    '--nxWorkspaceRoot="C:/dev/workspace/open-source"',
    'g',
    'qwik-nx:preset',
    '--no-a',
    '--no-g',
    '--$0=C:\\Users\\MyUser\\AppData\\Local\\pnpm\\store\\v3\\tmp\\dlx-19560\\node_modules\\create-nx-workspace\\bin\\index.js',
    '--packageManager=pnpm',
    '--defaultBase=main'
  ]
}

Node.js v18.7.0
 ERROR  Command failed with exit code 1: C:\Users\MyUser\AppData\Local\pnpm\store\v3\tmp\dlx-19560\node_modules\.bin\create-nx-workspace.CMD --preset qwik-nx

pnpm: Command failed with exit code 1: C:\Users\MyUser\AppData\Local\pnpm\store\v3\tmp\dlx-19560\node_modules\.bin\create-nx-workspace.CMD --preset qwik-nx
    at makeError (C:\Users\MyUser\AppData\Roaming\nvm\v18.7.0\node_modules\pnpm\dist\pnpm.cjs:22852:17)
    at handlePromise (C:\Users\MyUser\AppData\Roaming\nvm\v18.7.0\node_modules\pnpm\dist\pnpm.cjs:23423:33)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler [as dlx] (C:\Users\MyUser\AppData\Roaming\nvm\v18.7.0\node_modules\pnpm\dist\pnpm.cjs:202440:7)
    at async C:\Users\MyUser\AppData\Roaming\nvm\v18.7.0\node_modules\pnpm\dist\pnpm.cjs:209882:21
    at async main (C:\Users\MyUser\AppData\Roaming\nvm\v18.7.0\node_modules\pnpm\dist\pnpm.cjs:209853:34)
    at async runPnpm (C:\Users\MyUser\AppData\Roaming\nvm\v18.7.0\node_modules\pnpm\dist\pnpm.cjs:210079:5)
    at async C:\Users\MyUser\AppData\Roaming\nvm\v18.7.0\node_modules\pnpm\dist\pnpm.cjs:210071:7

Desktop (please complete the following information):

dmitry-stepanenko commented 1 year ago

For some reason ensurePackage function doesn't add packages when used within create-nx-workspace

dmitry-stepanenko commented 1 year ago

On macOS 10.15.6 it fails with the following

 >  NX   Cannot find module '@nxkit/playwright'

   Require stack:
   - /Users/dmitriy/projects/test/cuterepo/node_modules/qwik-nx/src/generators/application/lib/add-e2e-project.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/qwik-nx/src/generators/application/generator.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/qwik-nx/src/generators/preset/generator.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/src/config/workspaces.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/src/config/configuration.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/src/command-line/generate.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/src/command-line/nx-commands.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/bin/init-local.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/bin/nx.js
   Pass --verbose to see the stacktrace.

 >  NX   Failed to apply preset: qwik-nx
giri-jeedigunta commented 1 year ago

On macOS 10.15.6 it fails with the following

 >  NX   Cannot find module '@nxkit/playwright'

   Require stack:
   - /Users/dmitriy/projects/test/cuterepo/node_modules/qwik-nx/src/generators/application/lib/add-e2e-project.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/qwik-nx/src/generators/application/generator.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/qwik-nx/src/generators/preset/generator.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/src/config/workspaces.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/src/config/configuration.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/src/command-line/generate.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/src/command-line/nx-commands.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/bin/init-local.js
   - /Users/dmitriy/projects/test/cuterepo/node_modules/nx/bin/nx.js
   Pass --verbose to see the stacktrace.

 >  NX   Failed to apply preset: qwik-nx

I'm seeing the same error ... This is what I have

node v16.19.0 create-nx-workspace@15.6.3

dmitry-stepanenko commented 1 year ago

@giri-jeedigunta as a workaround for now you can use npx create-nx-workspace --preset qwik-nx --e2eTestRunner=none.

giri-jeedigunta commented 1 year ago

@giri-jeedigunta as a workaround for now you can use npx create-nx-workspace --preset qwik-nx --e2eTestRunner=none.

This works !!! I'm able to move forward

DominikPieper commented 1 year ago

The error appears with just the app generator in a fresh Nx workspace as well. At least for me some minutes ago. So maybe not a preset issue alone

dmitry-stepanenko commented 1 year ago

@DominikPieper can you please provide error logs or reproduction steps (along with versions/environment you are using)? I don't see any issues with app generator as of now

DominikPieper commented 1 year ago

@dmitry-stepanenko If I call the generator twice, the second call works as expected. I'll take a deeper look later

Steps:

npx create-nx-workspace@latest nx-qwik-test (used the integrated scheme)
npm install --save qwik-nx
npx nx g qwik-nx:app app

Logs:

npx nx g qwik-nx:app app --verbose

>  NX  Generating qwik-nx:application

✔ Which stylesheet format would you like to use? · css
added 1 package, removed 32 packages, and audited 350 packages in 796ms

31 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

 >  NX   Cannot find module '@nxkit/playwright'

   Require stack:
   - /private/tmp/nx-qwik-test/node_modules/qwik-nx/src/generators/e2e-project/generator.js
   - /private/tmp/nx-qwik-test/node_modules/qwik-nx/src/generators/application/generator.js
   - /private/tmp/nx-qwik-test/node_modules/nx/src/config/workspaces.js
   - /private/tmp/nx-qwik-test/node_modules/nx/src/config/configuration.js
   - /private/tmp/nx-qwik-test/node_modules/nx/src/command-line/generate.js
   - /private/tmp/nx-qwik-test/node_modules/nx/src/command-line/nx-commands.js
   - /private/tmp/nx-qwik-test/node_modules/nx/bin/init-local.js
   - /private/tmp/nx-qwik-test/node_modules/nx/bin/nx.js

Error: Cannot find module '@nxkit/playwright'
Require stack:
- /private/tmp/nx-qwik-test/node_modules/qwik-nx/src/generators/e2e-project/generator.js
- /private/tmp/nx-qwik-test/node_modules/qwik-nx/src/generators/application/generator.js
- /private/tmp/nx-qwik-test/node_modules/nx/src/config/workspaces.js
- /private/tmp/nx-qwik-test/node_modules/nx/src/config/configuration.js
- /private/tmp/nx-qwik-test/node_modules/nx/src/command-line/generate.js
- /private/tmp/nx-qwik-test/node_modules/nx/src/command-line/nx-commands.js
- /private/tmp/nx-qwik-test/node_modules/nx/bin/init-local.js
- /private/tmp/nx-qwik-test/node_modules/nx/bin/nx.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (/private/tmp/nx-qwik-test/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at /private/tmp/nx-qwik-test/node_modules/qwik-nx/src/generators/e2e-project/generator.js:35:73
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Nx Report:


npx nx report

 >  NX   Report complete - copy this into the issue template

   Node : 18.13.0
   OS   : darwin x64
   npm  : 8.19.3

   nx : 15.6.3
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.6.3
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.6.3
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : Not Found
   @nrwl/js : 15.6.1
   @nrwl/linter : 15.6.3
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : Not Found
   @nrwl/workspace : 15.6.3
   @nrwl/vite : 15.6.1
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
     qwik-nx: 0.9.0
     @nxkit/playwright: 2.1.0
``
dmitry-stepanenko commented 1 year ago

Thank you, @DominikPieper! Will take a look

dmitry-stepanenko commented 1 year ago

It seems that this is a bug in the nodejs https://github.com/nodejs/node/issues/44663

At this point it makes sense to adjust third-party package instead of creating workarounds here.

@sebastiandg7 can you please take a look at the fix in your repo please https://github.com/nxkit/nxkit/pull/59 🙏

sebastiandg7 commented 1 year ago

Thank you! I'm releasing the fix asap. Will it be worth to cover this with e2e tests?

dmitry-stepanenko commented 1 year ago

Thanks a lot @sebastiandg7 ! Yes, I will cover this with e2e tests for sure

sebastiandg7 commented 1 year ago

Just released @nxkit/playwright v2.1.1 with @dmitry-stepanenko's fix (thanks!). Opened #76 updating our dependency.

dmitry-stepanenko commented 1 year ago

Thank you @sebastiandg7 !

shairez commented 1 year ago

this still happens to me even when using npx

Tried to break it into manual steps like @DominikPieper suggested but getting this after running:

npx nx g qwik-nx:preset --verbose

image

DominikPieper commented 1 year ago

@shairez talked to Giora about the e2e tests at Discord, maybe easier to break down this one after we get tests to cover the preset as well. Easier to test with automation deploy and test cycles

sebastiandg7 commented 1 year ago

@shairez @dmitry-stepanenko this seems to be a different error breaking the preset generator, but we couldn't get to that point because of the one we just fixed. Seems like the playwright project generator is not getting the name option passed. Will take a look at that. Can we re open this issue?

dmitry-stepanenko commented 1 year ago

@sebastiandg7 this is now fixed https://github.com/qwikifiers/qwik-nx/pull/79. Haven't setup e2e as I know Giora is working on it