'Next.js create-next-app won't work anymore

I have been able to get around and make Next.js apps a lot as of late. However, something changed and I cannot seem to find a solution to my issue. I run npx create-next-app <app name> and it hits me with an error and only creates the package.json. It then shows me this error. Any insight would be appreciated.

>npx create-next-app imageuploads3
Creating a new Next.js app in /Users/Jeremy!@#$%^%$#/Desktop/Code For Learning/imageuploads3.

Using yarn.

Installing dependencies:
- react
- react-dom
- next

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

Error: spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476: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:476:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn yarn',
  path: 'yarn',
  spawnargs: [
    'add',
    '--exact',
    '--cwd',
    '/Users/jeremy!@#$^%$#/Desktop/Code For Learning/imageuploads3',
    'react',
    'react-dom',
    'next'
  ]
}

Node.js v17.8.0

IIOS 12.3

npx create-react-app works just fine BTW.



Solution 1:[1]

It's because Yarn isn't enabled. You have two options:

  1. If you want to use NPM instead of Yarn, pass the --use-npm flag in:
$ npx create-next-app --use-npm myapp
  1. For Yarn, enable Corepack first:
$ corepack enable
$ npx create-next-app myapp

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mark G