Home > database >  what is the correct procedure to setup first nextjs app
what is the correct procedure to setup first nextjs app

Time:03-27

I've been trying to create a Nextjs app. The command I've been using or which once worked npx create-next-app throws:

Note: node -v 14.18.0

Using yarn.

Installing dependencies:
- react
- react-dom
- next

'yarn' is not recognized as an internal or external command,
operable program or batch file.
events.js:377
throw er; // Unhandled 'error' event
  ^

Error: spawn yarn ENOENT
at notFoundError (C:\Users\Degamber\AppData\Roaming\npm\node_modules\create-next- 
app\dist\index.js:100:3828)
at verifyENOENT (C:\Users\Degamber\AppData\Roaming\npm\node_modules\create-next- 
app\dist\index.js:100:4207)
at ChildProcess.e.emit (C:\Users\Degamber\AppData\Roaming\npm\node_modules\create-next- 
app\dist\index.js:100:4062)
at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess.e.emit (C:\Users\Degamber\AppData\Roaming\npm\node_modules\create-next- 
app\dist\index.js:100:4103)
at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12) {
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn yarn',
path: 'yarn',
spawnargs: [
'add',
'--exact',
'--cwd',
'C:\\Users\\Degamber\\Downloads\\xyz\\nextjs-blog',
'react',
'react-dom',
'next'
]
}
PS C:\Users\Degamber\Downloads\xyz>

otherwise the document says use this : npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/master/basics/learn-starter" although it works but I want to make it setup easily using npx create-next-app

CodePudding user response:

downgrade from the latest, install a prior version:

npx [email protected] appname

CodePudding user response:

This will fix it and allow you to keep using npm.

npx create-next-app@latest --use-npm

Reference

  • Related