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

create-nx-workspace with custom preset is broken on windows #16231

Closed
dmitry-stepanenko opened this issue Apr 11, 2023 · 3 comments · Fixed by #16473
Closed

create-nx-workspace with custom preset is broken on windows #16231

dmitry-stepanenko opened this issue Apr 11, 2023 · 3 comments · Fixed by #16473
Assignees
Labels
os: windows Issues that can only be replicated on Windows outdated scope: core core nx functionality type: bug

Comments

@dmitry-stepanenko
Copy link
Contributor

dmitry-stepanenko commented Apr 11, 2023

Current Behavior

When creating a new workspace on windows with custom preset, it throws an error before spawning a process to generate the preset.

Expected Behavior

I debugged this to a certain point but can't publish Nx packages locally to test the fix all together due to a poor windows environment that I have access to right now.

I believe that replacing the spawn from child_process package with a cross-spawn here nx\packages\workspace\src\generators\new\generate-preset.ts should address the issue.

GitHub Repo

No response

Steps to Reproduce

  1. run npx create-nw-workspace@latest myrepo --preset=qwik-nx (instead of qwik-nx you can use any other package that has preset generator, it doesn't matter
  2. notice the error

Nx Report

The issue occurs before we're getting to the repository where "nx report" can be run. below there's relevant system information:

Node : 16.20.0
OS   : win32 x64

Failure Logs

npx create-nx-workspace@latest --preset=qwik-nx

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

√ Repository name                       · myrepo
√ Enable distributed caching to make your CI faster · No

 >  NX   Nx is creating your v15.9.2 workspace.

   To make sure the command works reliably in all environments, and that the preset is applied correctly,
   Nx will run "npm install" several times. Please wait.

✔ Installing dependencies with npm
✔ Nx has successfully created the workspace: myrepo.
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: spawn npx ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
    at onErrorNT (node:internal/child_process:485:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
    at onErrorNT (node:internal/child_process:485:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn npx',
  path: 'npx',
  spawnargs: [
    'nx',
    '--nxWorkspaceRoot="C:/Users/username/projects/test"',
    'g',
    'qwik-nx:preset',
    '--quiet',
    '--interactive',
    '--preset=qwik-nx',
    '--no-allPrompts',
    '--no-a',
    '--no-g',
    '--$0=..\\..\\AppData\\Local\\npm-cache\\_npx\\505743838affa773\\node_modules\\create-nx-workspace\\bin\\index.js',
    '--name=myrepo',
    '--appName=',
    '--packageManager=npm',
    '--defaultBase=main'
  ]
}

Additional Information

No response

@AgentEnder AgentEnder added scope: core core nx functionality os: windows Issues that can only be replicated on Windows labels Apr 11, 2023
@AgentEnder AgentEnder self-assigned this Apr 11, 2023
@gitLinda
Copy link

Also having this issue with my preset

@wimme
Copy link

wimme commented Apr 17, 2023

I also have it without preset:

PS C:\web\test> npx create-nx-workspace WebApps
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

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

√ Choose what to create                 · integrated
√ What to create in the new workspace   · angular-monorepo
√ Application name                      · dashboards
√ Would you like to use Standalone Components in your application? · Yes
√ Would you like to add routing? · No
√ Default stylesheet format             · scss
√ Enable distributed caching to make your CI faster · No

 >  NX   Nx is creating your v15.9.2 workspace.

   To make sure the command works reliably in all environments, and that the preset is applied correctly,
   Nx will run "npm install" several times. Please wait.

- Installing dependencies with npmnpm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
√ Installing dependencies with npm
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
√ Nx has successfully created the workspace: web-apps.
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\WINDOWS\system32\cmd.exe ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\WINDOWS\\system32\\cmd.exe',
  path: 'C:\\WINDOWS\\system32\\cmd.exe',
  spawnargs: [ '/d', '/s', '/c', '"git rev-parse --is-inside-work-tree"' ]
}

@github-actions
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
os: windows Issues that can only be replicated on Windows outdated scope: core core nx functionality type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants