简体   繁体   English

设置第一个 nextjs 应用程序的正确程序是什么

[英]what is the correct procedure to setup first nextjs app

I've been trying to create a Nextjs app .我一直在尝试创建一个Nextjs app The command I've been using or which once worked npx create-next-app throws:我一直在使用或曾经有效的命令npx create-next-app抛出:

Note: node -v 14.18.0注: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否则文档说使用这个: npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/master/basics/learn-starter"虽然它有效,但我想使用npx create-next-app轻松设置它

This will fix it and allow you to keep using npm.这将修复它并允许您继续使用 npm。

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

Reference参考

downgrade from the latest, install a prior version:从最新版本降级,安装以前的版本:

npx create-next-app@11.1.4 appname

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为 nextjs 项目设置关键 css 并删除不需要的 CSS 的正确方法 - correct way to setup critical css for nextjs project and remove unwanted CSS --example 标志在创建 NextJs 应用时的意义是什么 - What is the significance of the --example flag on creating NextJs app NextJs 和 Create React App 有什么区别? - What is the difference between NextJs and Create React App? 支持 es6 模块的正确设置是什么? - What is the correct setup to support es6 modules? 在 Google App Engine 上运行的 NextJs 应用程序的正确配置是什么? - What is the proper configuration for a NextJs app running on Google App Engine? 为 Nextjs 应用程序创建用户和管理员仪表板开关的最佳方法是什么? - What is the best way to create user and admin dashbaord switch for Nextjs app? React/Nextjs - 知道在 _app.js 上渲染了什么页面 - React/Nextjs - know what page is rendered on _app.js NextJS _app.tsx 组件和 pageProps 应该是什么 TypeScript 类型? - What TypeScript type should NextJS _app.tsx Component and pageProps be? 在 NextJS 项目上使用 Emotionjs 设置 Stylelint - Setup Stylelint with Emotionjs on a NextJS project 使用 Bootstrap 混合应用程序开发 ReactJS 的程序是什么 - what is the procedure to develop ReactJS with Bootstrap hybrid app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM