Next.js Tutorial - 1
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The error you're encountering, "Missing script: 'dev'," occurs because your package.json file does not have a script for running the development server (dev). In Next.js projects, the dev script is typically used to start the development server.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1. Create a pages directory or an app directory:
If you're using the Pages Router (traditional routing system):
- Create a
pagesdirectory at the root of your project.
- Create a
If you're using the App Router (available in newer versions of Next.js):
- Create an
appdirectory at the root of your project.
- Create an
2. Inside the directory, create an index.js (or index.tsx for TypeScript) file to serve as your home page.
pages/index.js, add the following:app/page.js, add the following:npm run dev