next.js не может быть запущен

#reactjs #next.js

#reactjs #next.js

Вопрос:

Для настройки next.js в окружающей среде мы выполнили команды в следующем порядке.
после его запуска я запустил yarn dev, но получил сообщение об ошибке.

ошибка

 warning package.json: No license field
error Command "dev" not found.
 

Команда выполнена

 ・yarn create next-app
・yarn add next react react-dom
・touch tsconfig.json
・yarn add --dev typescript @types/react @types/node
 

package.json

 {
  "name": "nextapp",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "next": "10.0.4",
    "react": "17.0.1",
    "react-dom": "17.0.1"
  }
}
 

Ответ №1:

В вашем "scripts" измените "dev" от "dev": "next dev" до "dev": "next" .

"scripts" должно выглядеть так:

   "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start"
  }